Luhn algorithm (modulo 10) used for credit card validation and many ID numbers Validates identification numbers to detect transcription errors.
| Property | Value |
|---|---|
| Category | Checksums |
| Sub-category | Check Digit Validation |
| Security status | π Educational Only |
| Complexity | Beginner |
| Inventor | Hans Peter Luhn (IBM) |
| Year | 1954 |
| Origin | πΊπΈ United States |
| Source | algorithms/checksum/check-digit.js |
Status: π Educational Only
| Issue | Description | Mitigation |
|---|---|---|
| Not Cryptographically Secure | Designed only for detecting accidental errors, not malicious attacks | β |
| Limited Security | Cannot protect against intentional manipulation by knowledgeable attackers | β |
3 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 β Valid test Visa card number
Source: Educational test vector
| Field | Value |
|---|---|
input |
04000000000000000000000000000002 |
expected |
01 |
Vector 2 β Invalid test Visa card number
Source: Educational test vector
| Field | Value |
|---|---|
input |
04000000000000000000000000000003 |
expected |
00 |
Vector 3 β Valid 12-digit number
Source: Educational test vector
| Field | Value |
|---|---|
input |
070909020703090807010308 |
expected |
01 |