Hawkynt

Luhn-Check-Digit

Luhn algorithm (modulo 10) used for credit card validation and many ID numbers Validates identification numbers to detect transcription errors.

Properties

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

Security

Status: πŸŽ“ Educational Only

Known vulnerabilities

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 β€”

Documentation

References

Test vectors

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

← All algorithms