Hello everyone,
How can I check the integrity of an individual's ID card number by typing 9 numbers by a user in python?
How can I check the integrity of an individual's ID card number by typing 9 numbers by a user in python?
|
individual's ID card number in python
|
|
Hello everyone,
How can I check the integrity of an individual's ID card number by typing 9 numbers by a user in python?
Jun-14-2018, 01:01 PM
well that depends - do you have algorithm (e.g. is there a check-sum number)? Note that you can check that it is correct based on algorithm, not that it is actually issued...
Or do you have access to a police/government database with valid ID numbers?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Jun-14-2018, 04:07 PM
You can search for already existing algorithms to generate checksums.
You can do also your own algorithm. A very simple implementation: def gen_checksum(number):
return number * 123 % 99
def num2id(number):
checksum = gen_checksum(number)
return number * 100 + checksum
def get_checksum(id_number):
number = id_number // 100
checksum = id_number - number * 100
return number, checksum
def check(id_number):
number, checksum = get_checksum(id_number)
return id_gen(number) == checksum
valid_numbers = [num2id(number) for number in range(1000, 1021)]
check(102027)The modulo 99 limits the checksum to 99.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians! |
|
|