Luhn Algorithm Explained
The Luhn algorithm is the checksum formula used to validate payment card numbers.
Buy live-checked CC and CVV on Dark Dollars
Dark Dollars is our live-checked shop for live-checked CC and CVV: every listing carries bin, brand, country, level and a verified balance band, with a check timestamp and replacement cover. Stock is validated before it is published, and delivery is digital and immediate once payment clears. Open darkdollars.st to buy live-checked CC and CVV or use the live links below.
Visit Our Store
Copy any address below to open our store. Green means online, red means currently unavailable.
CHECKING
What the Luhn algorithm is
The Luhn algorithm, also called the mod-10 algorithm, is a checksum used to validate identification numbers, including payment card numbers. It is not a security feature and it does not prove that a card exists. It simply catches most single-digit typing errors and some transpositions. A number that passes Luhn is well-formed; a number that fails is definitely wrong.
Why cards use a checksum
A long numeric string is easy to mistype. A checksum adds redundancy so a system can reject obvious errors before sending the number anywhere. The Luhn digit is calculated from the other digits and appended as the final digit. This is why a random sixteen-digit string usually fails validation, and why a single mistyped digit almost always does.
How the calculation works
Starting from the rightmost digit and moving left, double every second digit. If doubling produces a number above nine, subtract nine. Add all the digits together. A valid number's total is a multiple of ten. The final digit of the card number is chosen so that this holds. The calculation is simple enough to do by hand and is implemented in every card-format validator.
- Work from right to left
- Double every second digit
- Subtract 9 from results above 9
- Sum all digits; a valid number is a multiple of 10
A worked example
Take a number and apply the steps above: 4 5 3 9 5 7 8 7 6 3 6 2 1 4 8 6. Doubling every second digit from the right produces a set of values; after subtracting nine where needed, the total is a multiple of ten, so the number passes. Change any single digit and the total shifts, which is why the check is useful for catching typos.
What Luhn does not prove
Passing Luhn does not mean the card is live, funded or even issued. It only means the number is internally consistent. A card can pass Luhn and still decline, and a number can fail Luhn and be a deliberate test value. Use Luhn as a formatting gate before a live check, not as a validity result.
Using the tools
The free Luhn checker on this site validates the checksum in the browser without sending the number anywhere. The mod-10 calculator shows the working, and the card number validator combines length and checksum. For a real result, use the live checker. The sequence is always the same: format first, then validation.
Why some valid numbers fail Luhn
If a real card number fails a Luhn check, the most likely explanation is a transcription error: one digit mistyped, two digits swapped or a missing digit. Deliberately constructed test numbers can also fail. Failure does not mean the account does not exist; it means the string is not internally consistent. Re-enter the number from the source and run the check again before drawing any other conclusion.
Luhn in payment systems
Payment systems use Luhn as a cheap front-line check before a number reaches the issuer. It reduces obvious errors in forms and batch uploads without revealing anything about the account. It is not a security control: anyone can compute a valid check digit. Its value is purely in catching accidental mistakes, which is why it is paired with length and BIN checks rather than used alone.
Implementing the check mentally
A quick mental check is possible for short numbers. Work from the right, double every second digit, reduce values above nine by nine and keep a running total. If the total is a multiple of ten, the number passes. For long card numbers, the free calculator on this site does the same work without arithmetic mistakes. The mental version is useful for understanding the algorithm, not for processing batches.
A second worked example
Try a shorter number: 7992739871. From the right, double every second digit: the values become 7, 9, 9, 4, 7, 6, 9, 7, 7, 2. Summing them gives 67, so the check digit needed to reach a multiple of ten is 3, and the completed number is 79927398713. Running the same steps on the completed number returns a multiple of ten. This is the algorithm in its simplest form.
Why the algorithm uses mod 10
Mod 10 is convenient because it needs only addition and a single digit. It catches every single-digit substitution and most adjacent transpositions, which are the most common human errors. It does not need a database, a key or network access, so it can run anywhere. That combination of cheapness and coverage is why it became a standard for identification numbers rather than a cryptographic tool.
Implementation pitfalls
The common bugs are starting the doubling from the wrong side, failing to subtract nine from values above nine, and treating the number as a string with non-digit characters. Leading zeros, separators and spaces all need to be removed first. A correct implementation returns a boolean for the whole number and, optionally, the check digit for a prefix. Test it with known values before trusting it in a batch.
Luhn versus other check digits
Luhn is a general checksum, not a card-specific one. Other systems use weighted moduli, CRC checks or cryptographic signatures. Those offer different trade-offs between error detection and complexity. For card numbers, Luhn remains popular because it is simple, fast and good enough to catch typing errors. It is not designed to stop deliberate forgery, and it should never be presented as a security measure.
What a failed check means
A failed Luhn check means the digits are not internally consistent. The likely causes are a mistyped digit, a transposition, a truncated number or a deliberately constructed test value. It does not prove the account is invalid, and a passing check does not prove it is valid. Re-read the source, correct the format and run the check again. If it still fails, treat the number as malformed rather than guessing.
Teaching Luhn with examples
The algorithm is easier to learn by doing. Start with a short number, double every second digit from the right, reduce values above nine, sum and check the multiple of ten. Then try a longer card-length number with the free calculator and compare the running total. Once the pattern is clear, the check digit stops looking magical and becomes a simple parity-like rule that catches most typos.
Using test numbers safely
Test numbers are useful for validating an implementation, but they should be clearly fake and never mixed with real data. A generated number that passes Luhn is not a real account and should not be treated as one. Keep test values in a separate fixture, label them and avoid using them in production listings. The purpose of the algorithm is error detection, and the purpose of test data is to prove the detector works, not to create realistic-looking records.
Luhn and leading zeros
Leading zeros are a subtle case. A card number is a string of digits, not an integer, so a zero at the front must be preserved. If an implementation converts the value to a number, the leading zero disappears and the Luhn result changes. Always process the digits as characters, keep the original length and never trim the string. This is one of the most common bugs in small validation tools.
Frequently Asked Questions About Buying & Selling CC
What is the Luhn algorithm?
A mod-10 checksum used to validate identification numbers, including card numbers. It catches most typing errors but does not prove a card is valid.
Does passing Luhn mean the card is live?
No. Luhn only checks the number's internal consistency. A live checker is needed for a validation result.
How is the check digit calculated?
Double every second digit from the right, subtract nine from results above nine, sum the digits, and choose the final digit so the total is a multiple of ten.
Can a valid card fail Luhn?
A real card number should pass. A failure means the number was mistyped or constructed incorrectly.
Where is the free Luhn checker?
On this site. It runs in the browser and does not send the number to a server.
Is Luhn the same as a BIN lookup?
No. BIN lookup reads the issuer range; Luhn validates the whole number's checksum. They answer different questions.
Why would a real card fail Luhn?
Usually a mistyped or transposed digit, or a deliberately constructed test number. Re-check the source before assuming the account is invalid.
Is Luhn a security feature?
No. Anyone can compute a valid check digit. It only catches accidental errors and is combined with length and BIN checks.
Can I do Luhn by hand?
Yes for short numbers. For card-length inputs, use the free calculator to avoid arithmetic errors.
Is Luhn used outside payment cards?
Yes. It is used for several identification numbers, including some national ID and account formats, wherever a cheap checksum is useful for catching accidental typing errors.
Where do you start the doubling?
From the rightmost digit, doubling every second digit as you move left. Starting from the wrong side is the most common implementation bug.
Why mod 10?
It needs only addition and one digit, catches most typing errors and requires no key, database or network.
What does a failed Luhn check mean?
The digits are not internally consistent, usually because of a typo or truncation. It does not prove the account is invalid.
Is Luhn a security feature?
No. Anyone can compute a valid check digit. It is an error-detection checksum, not a security control.
How do I test an implementation?
Use known valid and invalid values, remove separators first and verify both the boolean result and the check-digit calculation.
Can a real card fail Luhn?
A real card number should pass. A failure usually means the number was mistyped or constructed, not that the account is unreal.
Are generated Luhn-valid numbers real cards?
No. A passing checksum only means the digits are internally consistent. Test numbers are not real accounts.
Why do leading zeros break Luhn checks?
Converting the string to a number removes the zero and changes the digit sequence. Treat the number as characters and preserve its length.
Does Luhn apply to IBANs?
IBANs use a different mod-97 check, not Luhn. Each identification system has its own checksum.
Can a valid Luhn check digit be zero?
Yes. Any digit from zero to nine is possible; the check digit is whatever makes the total a multiple of ten.
Why does Luhn catch transpositions?
Doubling alternate digits gives neighbouring positions different weights, so swapping two different digits usually changes the total and fails the check.
Is Luhn the same as a card's security code?
No. Luhn is a checksum on the card number itself. The security code is a separate printed value used for online payments, and it is not derived from the Luhn calculation.