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

Uploaded Source

File details

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

File metadata

  • Download URL: pyinid-0.4.8.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.8.tar.gz
Algorithm Hash digest
SHA256 30e44cc31945377f08755382d4f649dd75f59fa441194d7b387aeb5bbdb75023
MD5 380b11682c0262ef055a2f5035fbc03d
BLAKE2b-256 8b4bd6af5347edf023da2e3cf31282e5c08530cf3a8c5b29bb0f410320ed059a

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