A simple Python project to validate Iranian National Identification Numbers based on the official checksum algorithm. This project is implemented using Object-Oriented Programming (OOP) principles.
- Checks if the entered National ID is exactly 10 digits
- Ensures the input contains only numeric characters
- Rejects invalid IDs with all identical digits (e.g.,
1111111111
) - Implements the official checksum algorithm used for validation
- Clean and readable structure using Python classes
- Python 3.x
All libraries used are from Python’s standard library, so no additional packages are required.
-
The ID must be a 10-digit number.
-
All digits cannot be the same.
-
Compute the checksum as follows: checksum = (10×digit1 + 9×digit2 + ... + 2×digit9) % 11
-
Then:
- If
checksum < 2
, it must be equal to the 10th digit. - If
checksum >= 2
, then10th digit = 11 - checksum
.
- streamlit
- python