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.
| 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 |
Status: π Educational Only
No vulnerabilities are recorded for this implementation.
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 |