If you own a credit card, you will know that it contains a string of 16 digits where you have to key in when making an online purchase. At a glance, these numbers look random and there doesn’t seem to have pattern associated with it. The fact is, these number do follow a pattern and it is pretty simple to generate a series of valid credit card number. Let’s take a look at how credit card numbers work.
Note: A valid credit card number means that it can be validated by the algorithm used to encrypt the number. It doesn’t mean that you can use this number to make a purchase.
Decrypting the Credit Card Numbers
There are 16 digits in the credit card number and it can be divided into three parts.
1. The first digit represents the major industry identifier (MII). It identify the institution/industry that issues the card. For example, number that starts with:
- 1 and 2 are issued by airlines.
- 3 is issued by travel and entertainment, such as American Express and Diners Club.
- 4 is issued by VISA
- 5 is issued by MasterCard
- 6 is issued by merchandising and banking.
- 7 is issued by petroleum companies.
- 8 is issued by telecommunications companies.
- 9 is issued by national assignment.
Together with the next 5 digits, the first 6 digits of the string of number form the Issuer Identification Numbers (IIN). This will tell you who is the exact institution that distribute this credit card. If you can follow the pattern, a bank issuing a VISA credit card will have the first digit as “4” and the bank code for the next five digits. All VISA credit cards issued from this bank will have the same six beginning digits.
2. The 7th – 15th digits of the credit card number represent the customer account number. This is unique for each customer. It allows the bank to identify the owner of the card.
3. The last digit is a check digit that is used to verify the first fifteen digits. It makes use of the Luhn Algorithm (also known as Mod 10 algorithm). How it works is very simple:
- Write down your credit card number. Counting from the right, double the digit in the even position (2nd, 4th, 6th… 16th).
- If the doubled digit is more than 9, add up the number so it becomes a single digit. For example, if the doubled digit is
1314, add “1” to “4” so it becomes “5”.
- Now, add up all the numbers. The resulting number should be divisible by 10.
- Take the credit card number 3782 8224 6310 005
- Starting from the right, double the digits on the even position, this will give us: 3 14 8 4 8 4 2 8 6 6 1 0 0 0 5
- Adding up the digits for the number that is more than 9: 3 5 8 4 8 4 2 8 6 6 1 0 0 0 5
- Add up all the digits: 3 + 5 + 8 + 4 + 8 + 4 + 2 + 8 + 6 + 6 + 1 + 5 = 60 which is divisible by 10
If you work backward, you can easily work out the last digit of the credit card number.
For example, assume that the last number is unknown, so we have 3782 8224 6310 00x
- Starting from the right, double the digits on the even position, this will give us: 3 14 8 4 8 4 2 8 6 6 1 0 0 0 x
- Adding up the digits for the number that is more than 9: 3 5 8 4 8 4 2 8 6 6 1 0 0 0 x
- Add up all the digits: 3 + 5 + 8 + 4 + 8 + 4 + 2 + 8 + 6 + 6 + 1 + x = 55 + x. The nearest number that is divisible by 10 is 60, so x has to be 5
What is a CVV Number?
When you make an online purchase, other than the credit card number, the payment gateway will also ask you to enter a CVV number that is located at the back of the credit card. The CVV number is generated by encrypting the card number, expiry card and a secret encryption keys (which is unique for every issuing bank). This is a security feature and it is not easily crackable.
Resources for obtaining valid credit card numbers
If you are a developer and need to test your payment gateway without using your actual credit card number, you can make use of Credit card numbers generator to obtain a series of valid credit card numbers. You can select the issuing bank and number of entries. Paypal also comes with a list of credit card numbers that you can use to test.
Now that you know the “secret” to your credit card numbers, you can go ahead and test it out with your credit cards.