The Luhn algorithm test is a mod-10 checksum that runs across a string of digits and returns one of two answers: pass or fail. It was built to catch typing errors in long identification numbers, and it is still the check applied to payment card numbers, IMEI numbers on phones, and several national provider and account identifiers. A number that passes is well formed as a digit string. A number that fails has almost certainly been mistyped. A pass says nothing about whether an account exists, is open, or may be charged.
The test answers a narrow question: does this digit sequence satisfy a simple arithmetic relation between all of its digits and the final digit. That final digit is called the check digit. It is calculated from the digits that precede it, so a single wrong digit, a dropped digit, or two digits swapped out of order will break the relation in nearly every case. The method is named for Hans Peter Luhn, who described it in a patent filed in the 1950s while working on number verification systems.
Two limits follow from that definition. First, the check is positional, so it catches most transpositions and single-digit mistakes but not all of them. Second, the relation is public and trivial to compute, which means anyone can generate a digit string that passes. The test is an error detector, not a security control.
Take the sequence 79927398713. Reading from the right, the digits in the doubling positions are 1, 8, 3, 2 and 9. Doubling gives 2, 16, 6, 4 and 18. Two of those exceed 9, so subtract 9 to get 7 and 9. The adjusted doubled values are 2, 7, 6, 4 and 9, which sum to 28. The digits that were left alone are 3, 7, 9, 7, 9 and 7, which sum to 42. The grand total is 70, and 70 divided by 10 leaves no remainder, so the sequence passes.
Change any one digit and the total shifts away from a multiple of 10. That is the whole mechanism.
A passing number can be invented in seconds by anyone who knows the rule. Because the check digit is derived from the preceding digits, a made-up body of digits can be completed with a correct check digit on the first attempt. The test therefore cannot distinguish a real issued number from a plausible fake. It cannot confirm that an account is active, that a line of credit exists, or that a transaction will be approved. Anyone using the test as a filter should treat it strictly as a typo screen applied before more meaningful validation.
Use both. Run the check in the browser to keep the form responsive, then run the same check on the server as the gate that actually decides. Keep one shared implementation so the two sides cannot drift apart.
Test your implementation against a set of known-good and known-bad numbers, including one where two adjacent digits are swapped, since that is the error class the algorithm handles best.
You will receive the digital voucher immediately.
All your data is transmitted with unbreakable SSL-RSA encryption.
You can give away, resell or keep the vouchers.
We are available for you 24 hours a day.
Be informed as soon as new vouchers are added or when there are discounts.