Skip to main content

South African ID number utilities

Project description


Utilities for working with South African ID numbers.

RSA ID Number Format

  • 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
  • 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)


$ pip install rsa-id-number


>>> import rsaidnumber
>>> id_number = rsaidnumber.parse('8801235111088')
>>> id_number.valid
>>> 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


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.0.3.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

rsa_id_number-0.0.3-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

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