Credit card validation complete guide
What's the Luhn algorithm?
Luhn algorithm (also known as MOD 10) by Hans Peter Luhn at IBM in 1954 The invention is a simple check-and-check formula for the verification of various identification numbers, especially credit card numbers. To date, all major credit cards (Visa, Mastercard, American) Express, Discover, etc.) uses this algorithm to generate and validate card numbers.
Luhn Algorithms are not encryption algorithms, and are designed to detect unexpected errors in digital input, such as single or adjacent digital alternations. Any single number error can be made Luhn algorithm detected.
Luhn Algorithm Steps
- From the top right of the card number (checkpoint), every number (i.e., position is even) multiplied by 2
- If multiplying 2 results greater than 9, minus 9
- Add all numbers (including those not multiplied by 2)
- If the sum can be divided by 10 (i.e., sum of mod 10 = 0), the number is verified by Luhn
Common credit card number rules
Visa:
Starts with a number of four, the card number is 13 or 16 bits.
Mastercard:
Starts with a number within 51-55 or 2221-2720 and the length is 16 bits.
American Express:
Starts with 34 or 37 and 15 bits length.
Discover:
16 bits long at 6011 or 65.
JCB:
Starts with 358-3589 and 16 bits length.
MII: Main industry identifier
The first number of the credit card number is MII (Major Industry). Identifier, Main Industry identifier) which directs the industry where the issuing bank is located:
- 0: ISO/TC 68 and other industries
- 1-2: Airline
- 3: Travel and recreation (Amex, Diners Club)
- 4-5: Banking and finance (Visa, Mastercard)
- 6: Business and banks (Discover, Federation)
- 7: Oil companies
- 8: Health care and telecommunications
- 9: States and Governments
Luhn verify pass ≠ real card number
Important tip: Through Luhn The algorithmic certification only indicates that the card number is in a legal format and does not represent the existence of the card number or its use for transactions. Actual credit card certification needs to be done through the bank authorization system. This tool is used for learning and testing purposes only.
How to use this tool
- Enter a credit card number in the input box (support for space format)
- Click "Certify" or press Enter
- Tools will show whether the steps are calculated in detail through Luhn verification, card type, MII information, Luhn algorithm
- Click on the Example button to quickly test various card types
PrivacyNotes
This tool is fully run in your browser and does not send any card number information to the server. All validation logic is pure front end. JavaScriptrealized. Please be assured of use, but it is recommended that real credit card information not be entered in the public network environment.
FAQ
Q: Why is Luhn's certification passed but the bank refused?
A:Luhn The algorithm only validates the format and does not verify whether the account exists, is valid or has any balance. The actual transaction authorization is required through the banking system.
Q: Can you test the payment system?
A: The verification function in front-end format that can be used to validate payment systems, but the actual payment integration test should use the sandbox test card number provided by each payment platform.
Q: What's the last credit card number?
A: Last known as Check Digit by Luhn The algorithm is calculated on the basis of all previous figures and is used to detect input errors.