stdnum.damm¶
The Damm algorithm.
The Damm algorithm is a check digit algorithm that should detect all single-digit errors and all adjacent transposition errors. Based on anti-symmetric quasigroup of order 10 it uses a substitution table.
This implementation uses the table from Wikipedia by default but a custom table can be provided.
More information:
>>> validate('572')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> calc_check_digit('572')
'4'
>>> validate('5724')
'5724'
-
stdnum.damm.
calc_check_digit
(number, table=None)¶ With the provided number, calculate the extra digit that should be appended to make it pass the Damm check.
-
stdnum.damm.
checksum
(number, table=None)¶ Calculate the Damm checksum over the provided number. The checksum is returned as an integer value and should be 0 when valid.
-
stdnum.damm.
is_valid
(number, table=None)¶ Checks to see if the number provided passes the Damm algorithm.
-
stdnum.damm.
validate
(number, table=None)¶ Checks to see if the number provided passes the Damm algorithm.