Luhn check
A simple checksum formula whose last digit lets software spot mistyped card numbers and other identification numbers.
In more detail
Starting from the right, every second digit is doubled, nine is subtracted from any result above nine, and all the digits are added; a valid number gives a total that is a multiple of ten. It catches any single wrong digit and most swaps of neighbouring digits, but it is not security, since anyone can compute it. Card number scanners use it to weed out false alarms, such as order and phone numbers of the right length.
Examples
def luhn_ok(digits): ... return total % 10 == 0line 1: 773022******4408 fails Luhn, not a cardRelated terms
- checksum — A small value calculated from data and stored or sent with it, so the data can later be checked for accidental errors.
- PAN — The primary account number: the long number on a payment card that identifies the card account.
- false positive — A check result that claims something is true when it is not, such as a test passing on broken code or a tool flagging correct code.
- DLP — Data loss prevention: tools that watch for sensitive data leaving an organisation, such as customer records sent to a personal address.
Taught in
- Guardrails, Privacy And Governance — AI Engineering: LLM Apps, RAG & Agents
- Regulatory Compliance: SOC 2, HIPAA, GDPR & PCI-DSS — Cybersecurity Fundamentals, GRC & Cryptography
- Data Loss Prevention & Egress Monitoring — Cybersecurity Fundamentals, GRC & Cryptography