Skip to main content

Validate And Generate Iran National ID

Project description

pyINID

Iran National ID Tools

  • Check validity of Iran National ID as the following algorithm:

    Checksum Algorithm

    (checksum will be the rightmost digit of National ID code )

  • Generate a random valid Iran National ID prefixed with desired numbers

Installation

[sudo -H ]pip(3) install pyinid

Using as a library

Check validity

import inid

if inid.check_id('0123456789'):
	print("Correct")
else: 
	print("Incorrect")

or use class based approach:

import inid

obj1 = inid.INID("0012345679")
obj1.is_valid() # True

obj2 = inid.INID("001234567")  # incomplete
obj1.value  # True

# iterate through all NIDs
for nid in inid.INID_RANGE():
	print(nid)

# all NIDs for one/multiple cities
for nid in inid.INID_RANGE(city_codes=inid.CITY_CODES['تهران']['تهران مرکزی']):
	print(nid)

# all NIDs for one/multiple cities from a range
for nid in inid.INID_RANGE(100, 777, city_codes=inid.CITY_CODES['تهران']['تهران مرکزی']):
	print(nid)
	

Generate

import inid
print(inid.generate_id())		# Completely Random
print(inid.generate_id('12345'))	# With Desired Prefix
print(inid.generate_id('123456789'))	# Only generate checksum

Using as a cli tool

$ python3 -m inid

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

pyinid-0.4.7.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file pyinid-0.4.7.tar.gz.

File metadata

  • Download URL: pyinid-0.4.7.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.9.0 requests-toolbelt/0.8.0 tqdm/4.40.2 CPython/3.6.9

File hashes

Hashes for pyinid-0.4.7.tar.gz
Algorithm Hash digest
SHA256 279f59f0ec01f05c8c62832d547adcfa2ad824efad3d54215ea630fbf0183ba9
MD5 ff9f3444c218fdbdda1e3a4031c599d0
BLAKE2b-256 2bb189771a2be0a97ae9a2212293b03af6f2f908b81f3d868c9dbcbbea68f64c

See more details on using hashes here.

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