The Accidental Ancestor β How Verifying Numbers Shaped Modern Hashing
Article URL: https://0xkrt26.github.io/math_behind_security/2026/04/28/the-accidental-ancestor-Luhn-algorithm.html Comments URL: https://news.ycombinator.com/item?id=47941019 Points: 1 # Comments: 0
Article URL: https://0xkrt26.github.io/math_behind_security/2026/04/28/the-accidental-ancestor-Luhn-algorithm.html
Comments URL: https://news.ycombinator.com/item?id=47941019
1954, Hans Peter Luhn filed for a US patent on a Computer for Verifying Numbers. This is one of the earliest examples of using mathematical transformations to verify data integrity, a concept that became a foundation for modern hashes. Today you can find it under names Luhn Algorithm, Luhn Formula or Modulus 10 Algorithm.
To do that multiply the original digit by two. If result is 10 or bigger, add the digits. A substitution for the first digit from our example would be
but if the original number was 7, its substitution would be
Starting from the first digit on the right and moving left, replace every other digit with its substitution. Later the check digit will be appended in its original form on the rightmost position. This way we can avoid unnecessary calculations, as we wonβt have to calculate its substitution.
To do that add all the digits from the number from step 2. Take modulo 10 of this sum and subtract it from 10. Thatβs your check digit.
In the original paper Luhn performs modulo 10 operation each time the addition happens