South African ID number utilities
Project description
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.
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
rsa_id_number-0.1.0.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rsa_id_number-0.1.0.tar.gz.
File metadata
- Download URL: rsa_id_number-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7750e5dbe96b3a8d8a67b83bed740f8fd7fed01c7c5fbe918e0cea349c17f462
|
|
| MD5 |
9327b9fe5b7a6b85ea973af588c8ec7f
|
|
| BLAKE2b-256 |
a8aee65250eef4ff88fdd296c1bf771bd85573efee11a93c45e696f7516a580b
|
File details
Details for the file rsa_id_number-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rsa_id_number-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16a785e493277daf873621cef6e7ce50df42a930799e85a507ae0647732df0bb
|
|
| MD5 |
99af1b8e4869135ec9111cccb804327d
|
|
| BLAKE2b-256 |
c5bb37ea2c3ae2df6182c77a7b3ade05e81f9927e6c371fdfe3e36a21b9b3114
|