The Verhoeff algorithm.

The Verhoeff algorithm is a checksum algorithm that should catch most common (typing) errors in numbers. The algorithm uses two tables for permutations and multiplications and as a result is more complex than the Luhn algorithm.

More information:

The module provides the checksum() function to calculate the Verhoeff checksum a calc_check_digit() function to generate a check digit that can be append to an existing number to result in a number with a valid checksum and validation functions.

>>> validate('1234')
Traceback (most recent call last):
InvalidChecksum: ...
>>> checksum('1234')
>>> calc_check_digit('1234')
>>> validate('12340')

Calculate the extra digit that should be appended to the number to make it a valid number.


Calculate the Verhoeff checksum over the provided number. The checksum is returned as an int. Valid numbers should have a checksum of 0.


Check if the number provided passes the Verhoeff checksum.


Check if the number provided passes the Verhoeff checksum.