Skip to main content

Utilities for managing Icelandic national IDs (kennitala) safely and efficiently

Project description

ice-ken

Release CI

Utilities for managing Icelandic national IDs (kennitala) safely and efficiently.

Features

  • Modern Python packaging with pyproject.toml
  • src/ layout for clean imports
  • Python 3.9+ compatible
  • Normalize, format, validate, and mask kennitala

Installation

Install from PyPI (once published):

python3 -m pip install ice-ken

Install locally for development:

python3 -m pip install -e .

Usage

from ice_ken import __version__, normalize, is_valid, parse, format_kennitala, mask, is_company, is_personal

raw = "120174-3399"
digits = normalize(raw)                # "1201743399"
formatted = format_kennitala(digits)   # "120174-3399"
valid = is_valid(raw)                  # True/False (strict: checksum enforced)
valid_relaxed = is_valid(raw, enforce_checksum=False)  # True/False (relaxed)
masked = mask(raw)                     # "******-3399"
print(is_company(raw), is_personal(raw))  # e.g., False True

if valid:
 info = parse(raw)
 print(info.birth_date)             # datetime.date(...)

# Parse in relaxed mode (skip checksum enforcement)
info_relaxed = parse("120160-3379", enforce_checksum=False)
print(info_relaxed.formatted)

Validation Modes

  • Strict: is_valid(value) enforces the Modulus 11 check digit (9th digit).
  • Relaxed: is_valid(value, enforce_checksum=False) skips the check digit while still enforcing structure and date.

Example:

from ice_ken import is_valid

print(is_valid("120160-3389"))                         # True (passes checksum)
print(is_valid("120160-3379", enforce_checksum=False))  # True (ignores checksum)
print(is_valid("120160-3379"))                          # False (fails checksum)

Companies vs Individuals

  • Personal IDs: DD in 01–31 (calendar day)
  • Company/legal entity IDs: DD in 41–71 (day + 40 rule)

Quick checks:

from ice_ken import is_company, is_personal

print(is_personal("120160-3389"))   # True
print(is_company("520160-3379"))    # True (company: 52 → day 12)

Generate Test IDs

Create random kennitalas for development and testing:

from ice_ken import generate_personal, generate_company, is_valid

# Personal (strict checksum)
kt_person = generate_personal()                 # e.g., "DDMMYY-NNNX"
print(is_valid(kt_person))                      # True

# Personal (relaxed, checksum not enforced)
kt_person_relaxed = generate_personal(enforce_checksum=False)
print(is_valid(kt_person_relaxed, enforce_checksum=False))  # True

# Company (strict checksum)
kt_company = generate_company()
print(is_valid(kt_company))                      # True

# Company (relaxed)
kt_company_relaxed = generate_company(enforce_checksum=False)
print(is_valid(kt_company_relaxed, enforce_checksum=False))  # True

# Get raw 10-digit form instead of formatted
raw_digits = generate_personal(formatted=False)  # e.g., "DDMMYYNNNPC"

Synthetic Dataset Helper

Registers Iceland's synthetic dataset (Gervigögn) distinguishes test kennitalas by placing 14 or 15 in positions 7–8. For test-only detection, use:

from ice_ken import is_dataset_id

print(is_dataset_id("120160-1489"))  # True
print(is_dataset_id("120160-3389"))  # False

Note: This is a dataset convention for testing; do not rely on it in production.

Documentation

For a detailed explanation of kennitala structure, century and checksum rules, and policy notes, see docs/about-kennitala.md.

Policy Notice (February 18, 2026)

Registers Iceland will begin issuing kennitalas without a computed Modulus 11 check digit starting Feb 18, 2026. After this date, prefer relaxed validation (enforce_checksum=False) unless business requirements mandate the legacy parity check. See docs/about-kennitala.md for details and testing guidance.

Contributing

Contributions are welcome and encouraged! This project aims to provide reliable, well-tested utilities for working with Icelandic kennitalas.

How to Contribute

  1. Fork the repository and create your feature branch
  2. Follow the development setup in AGENTS.md
  3. Add tests for any new functionality
  4. Follow Conventional Commits for commit messages
  5. Submit a Pull Request — all PRs are reviewed by the repository owner

What We're Looking For

  • Bug fixes and improvements to existing functionality
  • Additional validation helpers and utilities
  • Documentation enhancements and examples
  • Test coverage improvements and edge cases
  • Performance optimizations
  • Support for additional use cases

Guidelines

  • Keep changes focused and well-documented
  • Ensure all tests pass before submitting
  • Add tests for new features or bug fixes
  • Update documentation when changing APIs
  • Follow the existing code style and patterns

We value all contributions, from typo fixes to major features. The Icelandic tech community benefits when we build robust, open-source tools together!

License

This project is licensed under the GNU General Public License v3.0 or later — see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ice_ken-1.0.2.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ice_ken-1.0.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file ice_ken-1.0.2.tar.gz.

File metadata

  • Download URL: ice_ken-1.0.2.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ice_ken-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bdcab7820bc8d1a12df7e1312211b45bcfb9aa5392654878abd0ff3f2141d68d
MD5 4c42243f81bb48103ba9fd5267b2e07f
BLAKE2b-256 b8630a914814d21adcba630678bbf9283d384a349ea5f77f903dc7e0343902aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for ice_ken-1.0.2.tar.gz:

Publisher: release.yml on vignirvignir/ice-ken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ice_ken-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ice_ken-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ice_ken-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfb8205003aaa324e9f1b0d094135f5bb92abfa2f82764baae7be8fe0c4f1e1c
MD5 5c2066c2d1e8f3ba5bef44249f07a09d
BLAKE2b-256 81c52bd5523a1fe02f69676bcffe1163a1fe33b5754192149793fafcd3888706

See more details on using hashes here.

Provenance

The following attestation bundles were made for ice_ken-1.0.2-py3-none-any.whl:

Publisher: release.yml on vignirvignir/ice-ken

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page