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.4.tar.gz (3.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pyinid-0.4.4.tar.gz
  • Upload date:
  • Size: 3.2 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.4.tar.gz
Algorithm Hash digest
SHA256 409379547784e500b264bce23672203a7a60e7c010c40f7d53e821396bde6df9
MD5 dc03a5912fc5cb4c70fbeaf6700490c2
BLAKE2b-256 0703e23d3d12eeee2fbde200c3f254882153f5d3795dcb57f60bb6a3739868aa

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