Tool for calculating and verifying numbers with Damm's algorithm. Generate check digits, detect input errors and secure your barcodes and identifiers.
Damm 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!
Damm's algorithm is a check digit / checksum calculation system designed to detect input errors in decimal numeric identifiers (serial numbers, administrative codes, etc.). Designed to be simple to implement by hand or programmatically, this algorithm detects all single substitution errors, all adjacent digit transpositions, as well as some multiple errors.
The calculation relies on the use of a unique substitution table, a quasigroup of order 10, known as a Damm table.
The calculation starts with c = 0. For each digit of the number, read from left to right, update c = table[c][digit].
| 0 | 3 | 1 | 7 | 5 | 9 | 8 | 6 | 4 | 2 |
| 7 | 0 | 9 | 2 | 1 | 5 | 4 | 8 | 6 | 3 |
| 4 | 2 | 0 | 6 | 8 | 7 | 1 | 3 | 5 | 9 |
| 1 | 7 | 5 | 0 | 9 | 8 | 3 | 4 | 2 | 6 |
| 6 | 1 | 2 | 3 | 0 | 4 | 5 | 9 | 7 | 8 |
| 3 | 6 | 7 | 4 | 2 | 0 | 9 | 5 | 8 | 1 |
| 5 | 8 | 6 | 9 | 7 | 2 | 0 | 1 | 3 | 4 |
| 8 | 9 | 4 | 5 | 3 | 6 | 2 | 0 | 1 | 7 |
| 9 | 4 | 3 | 8 | 6 | 1 | 7 | 2 | 0 | 5 |
| 2 | 5 | 8 | 1 | 4 | 3 | 6 | 7 | 9 | 0 |
Example: The final check digit is the value of c after processing all digits.
To verify a number, append the check digit, then process all digits: the final result must be 0.
Example: Example with 123:
Example:
| Iteration | Digit | Table | c |
|---|---|---|---|
| #1 | 1 | table[0][1]=3 | 3 |
| #2 | 2 | table[3][2]=5 | 5 |
| #3 | 3 | table[5][3]=4 | 4 |
The check digit is 4, so the number with checksum is 1234. To verify, process 1234 and the final c must be 0.
The algorithm guarantees detection of the following types of errors:
— All single substitution errors (replacing one digit with another, e.g.: $ 1234 \rightarrow 1239 $).
— All adjacent transpositions (swapping two adjacent digits, e.g.: $ 1234 \rightarrow 1324 $).
— Some multiple errors.
However, some complex permutations are not detected, such as circular permutations (e.g.: $ 1234 \rightarrow 4123 $) or some non-adjacent transpositions.
The time complexity is linear, $ O(n) $, where $ n $ is the number of digits in the sequence, since each digit is examined exactly once.
The space complexity is constant, $ O(1) $: the Damm table has a fixed size ($ 10 \times 10 $), which requires minimal memory space independent of the length of the data processed.
The Damm table is built from a quasigroup of order 10 with specific algebraic properties that guarantee detection of transposition and substitution errors. More precisely, the main diagonal of the table contains only zeros ($ N(x, x) = 0 $), and the mathematical structure satisfies strict antisymmetry conditions that prevent collisions when adjacent digits are swapped.
In the Damm table, $ \text{table}[0][0] = 0 $. Since the accumulator starts at $ c = 0 $, any zero at the start of the sequence leaves $ c $ unchanged at $ 0 $. Thus, 123, 0123 and 00123 produce exactly the same check digit ($ 4 $).
If the identifier length is variable and leading zeros are significant, enforce a fixed length or prefix the number with its length before calculation.
Yes, the method extends to any base $ n $ provided that a weakly totally antisymmetric quasigroup of order $ n $ exists. H. Michael Damm proved the existence of such quasigroups for all orders $ n \neq 2 $ and $ n \neq 6 $ (possible use in base $ 16 $ hexadecimal, base $ 32 $ or base $ 36 $ alphanumeric, but excluding base $ 2 $ binary and base $ 6 $).
The algorithm was introduced in 2004 by German mathematician H. Michael Damm in his doctoral thesis entitled Totally Antisymmetric Quasigroups.
dCode retains ownership of the "Damm Algorithm (Checksum)" source code. Any algorithm for the "Damm Algorithm (Checksum)" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Damm 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 "Damm 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 "Damm 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: Damm Algorithm (Checksum) on dCode.fr [online website], retrieved on 2026-11-12,