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

Uploaded Source

File details

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

File metadata

  • Download URL: pyinid-0.4.6.tar.gz
  • Upload date:
  • Size: 9.0 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.6.tar.gz
Algorithm Hash digest
SHA256 47ff27d7d7db6a69866a5a44b637e0ad8cfbf917f3f52ec711dbfb996f67a2b6
MD5 6d77374ffcaa855f5e07fbc506862e56
BLAKE2b-256 a8b04457d028da83d750bfb40d217d74047d02a1f5625226f3508bf1fe6f4fd1

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