Skip to main content

rsa-id-number

Utilities for working with South African ID numbers.

RSA ID Number Format

+-------------------------+
|8|8|0|1|2|3|5|1|1|1|0|8|8|
+-------------------------+
|Y|Y|M|M|D|D|S|S|S|S|C|A|Z|
+-------------------------+
  • YYMMDD: The first 6 digits represent the date of birth (23 January 1988)
  • SSSS: The next 4 digits are used to define the individual's gender (Male)
    • Female: 0000 - 4999
    • Male: 5000 - 9999
  • C: The next digit is used to classify citizenship (SA citizen)
    • SA citizen: 0
    • Permanent resident: 1
    • Refugee: 2
  • A: The next digit was used until 1980s to classify race
  • Z: The last digit is used as a checksum digit to verify the number (Valid)

Installation

$ pip install rsa-id-number

Usage

>>> import rsaidnumber
>>> id_number = rsaidnumber.parse('8801235111088')
>>> id_number.valid
True
>>> id_number.date_of_birth
datetime.datetime(1988, 1, 23, 0, 0)
>>> id_number.gender
<Gender.MALE: 2>
>>> id_number.citizenship
<Citizenship.SA_CITIZEN: 1>
>>> id_number = rsaidnumber.parse('8801235111080')
Traceback (most recent call last):
  ...
ValueError: '8801235111080' contains an invalid checksum digit!
>>> id_number = rsaidnumber.parse('8801235111080', False)
>>> id_number.valid
False

Support for temporary ID numbers issued to refugees can be opted into:
>>> id_number = rsaidnumber.parse('8012215312288', allow_refugee=True)
>>> id_number.valid
True

Contributing

Setup your development environment by running:

$ make

this will create a new Python virtualenv, install all necessary dependencies and run the tests.

Release files for rsa-id-number 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rsa-id-number 0.1.0
File Size Uploaded
rsa_id_number-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rsa-id-number 0.1.0
File Interpreter ABI Platform
rsa_id_number-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / rsa_id_number-0.1.0.tar.gz

Download URL rsa_id_number-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7750e5dbe96b3a8d8a67b83bed740f8fd7fed01c7c5fbe918e0cea349c17f462
BLAKE2b-256 checksum
How to use checksums
a8aee65250eef4ff88fdd296c1bf771bd85573efee11a93c45e696f7516a580b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / rsa_id_number-0.1.0-py3-none-any.whl

Download URL rsa_id_number-0.1.0-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16a785e493277daf873621cef6e7ce50df42a930799e85a507ae0647732df0bb
BLAKE2b-256 checksum
How to use checksums
c5bb37ea2c3ae2df6182c77a7b3ade05e81f9927e6c371fdfe3e36a21b9b3114
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page