# stdnum.verhoeff

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:

- https://en.wikipedia.org/wiki/Verhoeff_algorithm

- https://en.wikibooks.org/wiki/Algorithm_Implementation/Checksums/Verhoeff_Algorithm

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')
    1
    >>> calc_check_digit('1234')
    '0'
    >>> validate('12340')
    '12340'

stdnum.verhoeff.calc_check_digit(number: str) → str

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

stdnum.verhoeff.checksum(number: str) → int

  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: str) → bool

  Check if the number provided passes the Verhoeff checksum.

stdnum.verhoeff.validate(number: str) → str

  Check if the number provided passes the Verhoeff checksum.