stdnum.verhoeff¶
The Verhoeff algorithm.
The Verhoeff algorithm uses two tables for permutations and multiplications to calculate a checksum.
>>> validate('1234')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> checksum('1234')
1
>>> calc_check_digit('1234')
'0'
>>> validate('12340')
'12340'
Traceback (most recent call last):
...
InvalidChecksum: ...
-
stdnum.verhoeff.
calc_check_digit
(number)¶ With the provided number, calculate the extra digit that should be appended to make it pass the Verhoeff checksum.
-
stdnum.verhoeff.
checksum
(number)¶ Calculate the Verhoeff checksum over the provided number. The checksum is returned as an int. Valid numbers should have a checksum of 0.
-
stdnum.verhoeff.
is_valid
(number)¶ Checks to see if the number provided passes the Verhoeff checksum.
-
stdnum.verhoeff.
validate
(number)¶ Checks to see if the number provided passes the Verhoeff checksum.