Tool for calculating and verifying numbers using the Verhoeff algorithm (checksum). Generate check digits, detect input errors, and secure barcodes or identifiers.
Verhoeff Algorithm (Checksum) - dCode
Tag(s) : Checksum, Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Verhoeff's algorithm is a check digit calculation algorithm designed to detect input errors in decimal numeric identifiers (serial numbers, administrative IDs, etc.).
Verhoeff's algorithm can detect all single-digit substitution errors and all adjacent digit transpositions, as well as some multiple errors.
The algorithm uses three tables (index 0): the multiplication table (D) based on the dihedral group D5, the permutation table (P) which permutes the digits according to their position, the inverse table (I) which allows the calculation of the final check digit.
| D = | P = | I = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
Example: The initial number 123 has the digit 3 in position 1, the digit 2 in position 2, and the digit 1 in position 3 (read from right to left). Position 0 is for the checksum.
An iterative calculation (to calculate the checksum c) is applied, with an initialization of c = 0.
Example:
| Iteration | Position | Digit | Permutation | Multiplication | c |
|---|---|---|---|---|---|
| #1 | 1 | 3 | P[1][3]=6 | D[c=0][6]=6 | 6 |
| #2 | 2 | 2 | P[2][2]=0 | D[c=6][0]=6 | 6 |
| #3 | 3 | 1 | P[3][1]=9 | D[c=6][9]=2 | 2 |
The final checksum is calculated by looking in the inverse table based on the value of c.
Example: The checksum is I[2] = 3, so the number with the checksum is 1233.
Verhoeff's algorithm effectively detects several types of input errors:
— All simple substitution errors, where one digit is replaced by another (e.g., 1234 → 1239).
— All adjacent transpositions, where two neighboring digits are reversed (e.g., 1234 → 1324).
— Some multiple errors, where two or more digits are entered incorrectly simultaneously.
However, the algorithm does not detect certain complex permutations, such as circular permutations (e.g., 1234 → 4123) or some non-adjacent transpositions.
dCode retains ownership of the "Verhoeff Algorithm (Checksum)" source code. Any algorithm for the "Verhoeff Algorithm (Checksum)" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Verhoeff Algorithm (Checksum)" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Verhoeff Algorithm (Checksum)" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Verhoeff Algorithm (Checksum)" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Verhoeff Algorithm (Checksum) on dCode.fr [online website], retrieved on 2026-01-08,