Summary
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, named after its creator, IBM scientist Hans Peter Luhn, is a simple check digit formula used to validate a variety of identification numbers. It is described in U.S. Patent No. 2,950,048, granted on August 23, 1960. The algorithm is in the public domain and is in wide use today. It is specified in ISO/IEC 7812-1. It is not intended to be a cryptographically secure hash function; it was designed to protect against accidental errors, not malicious attacks. Most credit cards and many government identification numbers use the algorithm as a simple method of distinguishing valid numbers from mistyped or otherwise incorrect numbers. The check digit is computed as follows: If the number already contains the check digit, drop that digit to form the "payload". The check digit is most often the last digit. With the payload, start from the rightmost digit. Moving left, double the value of every second digit (including the rightmost digit). Sum the values of the resulting digits. The check digit is calculated by . This is the least number (possibly zero) that must be added to to make a multiple of 10. Other valid formulas giving the same value are , , and . Note that the formula will not work in all environments due to differences in how negative numbers are handled by the modulo operation. Assume an example of an account number 7992739871 (just the "payload", check digit not yet included): The sum of the resulting digits is 67. The check digit is equal to . This makes the full account number read 79927398713. Drop the check digit (last digit) of the number to validate. (e.g. 79927398713 -> 7992739871) Calculate the check digit (see above) Compare your result with the original check digit. If both numbers match, the result is valid. (e.g.). The Luhn algorithm will detect all single-digit errors, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence 09 to 90 (or vice versa).
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.