Search for a tool
Luhn Number Checksum

Tools to check Luhn generated numbers. The Luhn algorithm (also called modulo 10 or mod 10) is a checksum formula for numbers/digits used with credit card or administrative numbers.

Results

Luhn Number Checksum -

Tag(s) : Checksum, Arithmetics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Luhn Number Checksum' tool for free! Thank you!

Luhn Number Checksum

Numbers generated by Luhn Algorithm



See also: IBAN Number

Valid Number Generator


Number with Missing Digits


Answers to Questions (FAQ)

What is the Luhn Algorithm? (Definition)

Luhn's algorithm (or Luhn's formula or Luhn's key) is a verification algorithm used to validate various numbers (such as credit cards).

Its principle is to calculate, from a number (or a sequence of numbers), a control key (called checksum) which makes it possible to verify that the number is correct (because the key is a number which is dependent on the others) .

Invented by Hans Peter Luhn in 1954 and remains widely used in data processing systems.

What is the Luhn Algorithm for?

Luhn makes it possible to check numbers (credit card, gift card, IMEI, etc.) thanks to its control key (a digit which makes it possible to check the others digits). If a character is misread or badly written, then Luhn's algorithm will detect this error.

Luhn is known because MasterCard, American Express (AMEX), Visa and all credit cards use it.

Example: 12345674 is a valid card number, 1234567 is the initial number and 4 is the checksum.

Luhn's algorithm can quickly detect input errors, typos or invalid numbers before performing critical operations, such as processing credit card payments or identifying users.

Example: If a user enter 13245674 (2 and 3 are switched), then the program calculates the luhn checksum for 1324567 and finds 5 instead of 4 expected, the number is invalid and so the code has been badly typed.

How to verify a number with Luhn? (Validity check)

The Luhn algorithm starts by the end of the number, from the last right digit to the first left digit. Multiplying by 2 all digits of even rank. If the double of a digit is equal or superior to 10, replace it by the sum of its digits. Realize the sum $ s $ of all digits found. The control digit $ c $ is equal to $ c = (10 - (s \mod 10)) \mod 10 $.

Example: The number 853X, with X=0, the digit to calculate.
Take the digit 3, doubled, 3*2 = 6.
Takes the digit 5, not multiplied by 2
Take the 8, multiplies it by 2: 8*2=16 and 1+6=7 to get 7.
The sum is 6+5+7 = 18. As 18 modulo 10 = 8, one calculated (10 - 8) %10 = 2, 2 is the digit checksum control. So 8532 is valid according to Luhn.

8530
8*2=16stays 53*2=6stays 0
1+6=7560
s=7+5+6+0=18
c=10-(18%10)=2

How to generate a valid number with Luhn?

Indicate the number, calculate the Luhn key (or use the generator on this page) and concatenate the value found to the number.

What are Luhn's algorithm weaknesses?

The verification algorithm does not allow the detection of certain permutations of digits.

Example: The numbers 0123456789 and 9123456780 both have a checksum of value 7. Generally, this is the case for pairs 09 and 90: any number containing a 0 replaced by a 9 and a 9 replaced by a 0 has an identical checksum.

Another weakness is the failure to detect a double error like 22 from/to 55 or 33 from/to 66 or even 44 from/to 77.

Example: 001122 and 001155 have the same checksum.

The presence or absence of leading zeros 0 at the beginning of the number does not modify the checksum. It can be an advantage as well as a disadvantage.

Example: 000123 and 123 have the same checksum.

How to calculate a CVC/CVC1/CVV1/CVC2/CVV2 code?

CVC (Card Validation Code) or CVV (Card Validation Value) or verification codes are 3-digits located on the back of bank cards. Generated by the banks, Visa and MasterCard have their own algorithm (based on private key) using the personal account number, the expiry date of the card and the service code, this information is then compared by those calculated by the bank. There are even banks that offer to change these numbers at will.

Luhn's algorithm is not used to calculate these numbers, so they are impossible to calculate without knowing the generation method (and often the associated private key).

How to calculate the expiry date for a card?

The expiration date (expr/expiry date) is nothing but information on the card indicating the month and year until which the card is valid. It is not a value dependent on Luhn's algorithm, it is not computable. Its value is written on the front of the card in mm/yy format.

Can Luhn be used for gift cards codes?

The best practice for generating a gift card code is to generate a random number and associate a checksum with it, such as Luhn's algorithm. The code of the gift card is then stored in a database with its data (money, name, loyalty points, etc.). The use of Luhn makes it possible to ensure that the gift code is well written if it must be typed by a human or read by a machine. A person wanting to find the generation algorithm can not then achieve this, the random number ensuring too low probability of success.

NB: all gift card codes are unfortunately not based on a random generation and if they are deterministic, they are then subject to a security vulnerability allowing reverse engineering and potential generation at will.

Is Luhn used for credit cards magnetic stripe?

No, in the magnetic strip is the information of the credit card completed by a different checksum control: the Longitudinal redundancy check.

Source code

dCode retains ownership of the "Luhn Number Checksum" source code. Except explicit open source licence (indicated Creative Commons / free), the "Luhn Number Checksum" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Luhn Number Checksum" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Luhn Number Checksum" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Luhn Number Checksum" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Luhn Number Checksum on dCode.fr [online website], retrieved on 2024-11-21, https://www.dcode.fr/luhn-algorithm

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Luhn Number Checksum' tool for free! Thank you!


https://www.dcode.fr/luhn-algorithm
© 2024 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.
 
Feedback