How to use the verhoeff and damm check digit calculator
- Choose Verhoeff or Damm, and whether you want to add a check digit or check a number.
- Type the digits. Spaces and hyphens are ignored. When checking, include the check digit at the end.
- Read the check digit, or whether the number is valid, with the number written out in full.
- Follow the table to see each digit, the table entry it used and the running value after it.
Formula
Verhoeff: c = d[c][p[position mod 8][digit]], digits taken from the right
Verhoeff check digit = inv[c] after the payload, which starts at position 1
Damm: interim = table[interim][digit], digits taken from the left, starting from 0
valid when the final running value is 0 (the check digit included)
The Verhoeff tables come from the dihedral group of order 10, and the Damm table is a Latin square with zeros on its diagonal that is weakly totally anti-symmetric. Both properties are why every single error and neighbor swap is caught.
236 and 572
The Verhoeff check digit of 236 is 3, so 2363 is valid. Walking from the right, the digits 6, 3 and 2 give the running values 3, 1 and 2, and the inverse of 2 is 3. The Verhoeff check digit of 12345 is 1.
The Damm check digit of 572 is 4. The walk goes through the table entries 9, 7 and 4, so 5724 is valid. Changing 5724 to 5734 or swapping two digits to give 5274 makes the walk end somewhere other than 0, so the number is rejected.
Why these two methods
The Luhn method used on cards and the weighted sums used on barcodes miss some errors, such as certain swaps of neighboring digits. Verhoeff and Damm were designed to catch all single wrong digits and all swaps of two neighboring digits. The cost is a table lookup in place of simple arithmetic.
To check Luhn, ISBN and barcode digits, see the Check Digit Validator and the GS1 GTIN SSCC Check Digit Builder. For an IBAN, see the IBAN Structure Checker and Builder, and for whole files, the CRC32 Checksum Calculator.
What a check digit does not do
A check digit finds typing and copying mistakes. It does not show that a number was issued or belongs to anyone, and it is not a secret or a signature. Two wrong digits that cancel each other, or a swap of digits that are far apart, may still pass.
Assumptions and limits
- The input is digits only, up to 60 of them, with spaces and hyphens removed.
- In check mode the last digit is taken as the check digit.
- The standard Verhoeff permutation and multiplication tables and the standard Damm table are used.
- Leading zeros are kept.
- The tests compare the tool with a separate implementation and try every single error and neighbor swap.
Frequently asked questions
Which is better, Verhoeff or Damm?
Both catch all single errors and neighbor swaps. Damm uses one table and is simpler to code, and Verhoeff is older and used in some national ID systems.
Does either method catch every error?
No. They catch every single-digit error and every swap of neighboring digits, but some other mistakes can pass, such as certain swaps of digits far apart.
Can the check digit be 0?
Yes. Some numbers have a check digit of 0, and it counts like any other digit.
Is this the same as the Luhn check?
No. Luhn uses a doubling and sum rule. Verhoeff and Damm use tables, and they catch more neighbor swaps.