Hawkynt

Luhn

Luhn algorithm (mod 10 algorithm) for validating identification numbers. Invented by Hans Peter Luhn at IBM in 1954. Used in credit cards, IMEI, Canadian SIN. Detects all single-digit errors and most adjacent transpositions.

Properties

Property Value
Category Checksums
Sub-category Check Digit
Security status πŸŽ“ Educational Only
Complexity Beginner
Inventor Hans Peter Luhn (IBM)
Year 1954
Origin πŸ‡ΊπŸ‡Έ United States
Source algorithms/checksum/luhn.js

Security

Status: πŸŽ“ Educational Only

No vulnerabilities are recorded for this implementation.

Notes

Documentation

References

Test vectors

3 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 β€” Rosetta Code test vector 49927398716

Field Value
input 34393932373339383731
expected 06

Vector 2 β€” Rosetta Code test vector 1234567812345670

Field Value
input 313233343536373831323334353637
expected 00

Vector 3 β€” Simple Luhn test 12345674

Field Value
input 31323334353637
expected 04

← All algorithms