Generate a fake credit card for free to test your apps or to enter card details on a website. This credit card generator can generate VISA (13 and 16 digits), Mastercard, American Express, Discover and other major cards.
How is a credit card number generated?
We all have used a credit card or a debit card. All of these cards have a 16-digit (or 13-digit) number printed on the front side of the card. Do you think that these numbers are just random numbers? If you think so, you need to stand corrected. The digits of a credit card (and of course a debit card) are never random. They are all generated using specific rules.
Have you ever noticed that when you type in your credit card or debit card number on any e-commerce website, the web page will immediately flag a number as incorrect when you mistype even one digit? The real reason behind this is that there are safeguards (against typos) to each credit card or debit card number.
In this article on how a credit card number is generated, we will take a detailed look at the process of producing a credit card number. We will also try to understand what these numbers mean.
So, without further ado, let us begin.
Digits in Credit Card Number Describing Card Type
You may have a VISA card or a MasterCard or American Express card, or a JCB or a Discover card. The question is, how will a system identify what type of card you are using?
To ensure that a card is identified correctly, all credit cards will have a prefix number. This prefix number works as a unique identifier for a particular type of card. The table below gives the prefix numbers for some of the most popular cards in the world.
|Card Type||Prefix Number|
|American Express||34-, and 37-|
|MasterCard||51-, 52-, 53-, 54-, 55-|
|Diners Club||36-, and 38-|
The table above is not an exhaustive one. We gave the table so that you can get an idea of how a system identifies a card type.
Wondering whether we are right or now? Just pull out any debit card or credit card you have right now and check it.
Issuer Identification Number
Talking of credit card, while there is always a number that describes a card type, the first six digits are specifically designed to identify the issuer of a particular credit card.
So, suppose your credit care number is: 4875842557119863 (Please note that this is a fictitious number that we have created randomly. If it represents an actual credit card number, it is a mere accident, and we have absolutely no intentions of revealing anyone’s credit card number publicly).
Out of this, the first six digits will always identify the identity of the card issuing body. The first six digits go by the name Issuer Identification Number. A quick Google search can help you to find the complete list of Issuer Identification Number, and hence, we are conveniently skipping that part.
The Check Digit of a Credit Card Number
The last digit of a credit card number is known as the Check Digit. It is a deterministic digit. What does that mean? It means that the Check Digit is determined by the digits present before that digit.
The algorithm that is used for creating the Check Digit is known as the Luhn Algorithm.
What does this Check Digit do?
We often type in our credit card number on websites, we quote them, or we transfer them depending on the scenario in hand. The thing is that humans are involved in such transfers. Humans are prone to mistakes. So, it is quite likely that you may type in or misquote your credit card number.
The Check Digit is a safeguard that will immediately flag a number as an incorrect number if you provide a wrong number.
In our example credit card number (4875842557119863), the last digit is 3. This digit is the Check Number.
If we consider that this fictitious number is an actual credit card number and we can use it on a website to pay for some product or service then, the digit 3 will play a vital role in finding whether the number we input is correct or incorrect.
For instance, if we type in the number incorrectly as 4875842557116863, that is, we type in 6 instead of 9, the Check Digit that the Luhn Algorithm will generate will be something else other than 3. So, the disagreement will instantly flag the credit card number as incorrect.
How Luhn Algorithm Works?
Before we even go ahead and learn how the algorithm works, let us learn about Luhn.
Hans Peter Luhn was an engineer who worked for IBM. He created the exact mathematical formula that is required for generating the Check Digit. He invented this formula in the year 1954. After he created the formula, he patented it. Today, however, the formula is available publicly. It is used as a worldwide standard. The standard is known as ISO/IEC 7812-1
The method used for creating a Check Digit is not a foolproof method. Put in other words, it is possible for a hacker or a crook to guess a random credit card number that will have a right Check Digit at the end. However, the possibility or the probability of guess a correct credit card number with a correct Check Digit is meager. Only one out of ten guesses can be right. Sometimes, it may take even more guesses.
Good news, however, is that the algorithm is strong enough to find or detect the error caused by even a single digit typed or input incorrectly. For example, if you type 6 instead of 9, the Check Digit can catch that error.
Also, the Check Digit is very much capable of detecting nearly all pair-wise switching for any two adjacent numbers. The algorithm cannot identify the switching of 90 to 09 or vice versa.
Now that we know a bit about the background and the problems and strengths of the Luhn Algorithm let us try to understand how the algorithm works.
The Luhn Algorithm and its role in a credit card number:
Suppose the credit card number is: 4875842557119863 (this is the example that we used earlier).
In this example, 3 is the Check Digit. Since 3 is a deterministic number, it cannot be generated randomly. It has to be generated based on the digits that come before it. So, how is 3 determined?
Before using the Luhn Algorithm to find the Check Digit for a credit card number, the number should be a 15-digit number. So, as per our example, the number before determining ‘3’ should be 487584255711986.
Since a credit card number has to have 16 digits, let the last digit (that is the Check Digit) be ‘y.’
Now the credit card number should look like this: 487584255711986y.
To determine y, use the following rules:
- Start from the extreme right and pick the digits that sit in an even position.
- Now multiply all the evenly positioned digits by 2 (that is, double each one of them). If the multiplication turns a double-digit number, add the digits of that number so that you get a single digit.
- Now add all the numbers you get in the even position.
- Add all the original numbers that sit in the odd position.
- Add the sum you get in step #3 to the sum you get in step#4.
- Now see what you need to add to the total you get in step #5 to make it exactly divisible by 10. The digit that you need to add is the Check Digit.
Let us now take a look at the actual process.
|8||1+4 = 5||1+6 = 7||4||1+0 = 1||2||1+8 = 9||1+2 = 3||y|
Sum of all digits in the even position (from the right and after multiplying with 2) is = 39
Sum of all original digits in the odd position from the right is = 38
Sum of 39 and 38 is 77.
We need to add 3 to 77 to make it exactly divisible by 10 because adding 3 to 77 will yield 80 which is exactly divisible by 10.
Thus, our check digit is 3.
Fun Fact about this example we took
Did you know that even before we did the steps of Luhn Algorithm, we assumed the credit card number as 4875842557119863? We had no idea whether the Luhn Algorithm will return 3 for the last position (Check Digit) or not. It turns out that the mathematics yields 3.
This luck of ours shows that it is indeed possible for hackers and crooks to generate a credit card number randomly.
What about the rest of the digits in a credit card number?
Okay, we said that the first six digits represent the unique Issuer Identification Number. The last digit represents the Check Digit. That makes a total of seven digits. What about the remaining nine digits of the credit card number?
The rest of the numbers represent the unique account number against which the card is issued. The account number allows the issuing bank or financial organization to track all transactions accurately.
The digits in between may represent actual account number, or they may be random numbers that are mapped to a real account number. Since an issuing authority can issue multiple cards against a single account, the nine digits in question may be a sequence of numbers mapped to the actual account number.
A question you may ask about credit card number
You may come up and ask that if Luhn Algorithm is not that powerful in stopping a hacker or a crook from guessing a credit card number accurately, why use the method in the first place?
It is a brilliant question but, you are missing a critical aspect. A credit card has several safeguards in place. For instance, there is something called a card code that is present on the back side of the card.
This card code has different names. For instance, in the case of a VISA card, it is known as Card Verification Value or CVV2. In case of MasterCard, it is known as Card Verification Code or CVC. In the case of American Express cards, it is known as CID or Card Identification Number.
The verification code is unique to each card and is available only with the person owning the credit card and the bank or the institution issuing the card. The code is either a 3-digit number or a 4-digit number. Guessing the code is nearly impossible. Even if someone guesses the security code correctly, there is another layer of security which can be in the form of One Time Password (sent to a mobile number), or it can be a PIN that the bank or the card issuing institution provides for carrying out transactions using the card.
It is virtually impossible for a hacker to guess these numbers unless you provide the same to someone. Of course, an expert hacker can lay his or her on the bank servers and steal all credit card information directly from the bank server. In such a case, you cannot do anything. The bank will be responsible for the security lapse.
Security Tips and Conclusion
Sometimes, credit cards are a lifesaver. However, they are financial instruments. If they fall in wrong hands, you can be at a loss. So before we conclude this article, we will like to share some security tips with you:
- Never share your credit card number with anyone.
- Never share your CVV2 or CVC or CID number with anyone.
- If you require a PIN for completing your transaction using your credit card, make sure that you memorize the PIN instead of writing it down somewhere or keeping a digital copy of the same.
- If you require an OTP for completing a transaction, never share the OTP with anyone except the merchant.
- If you are transacting online, never carry out any transaction on a website which has not SSL protection. A site with SSL protection shows HTTPS protocol instead of HTTP protocol.
Now that we have shared the security tips let us conclude the article.
So, what we have learned today is that a lot of work goes behind creating or generating a credit card number. It is not that simple. There is a highly complicated mechanism behind each card number. So, your card number is not a set of random numbers. They have a particular meaning, and yes, there is a type of mathematics called modulo-10 (that the Luhn Algorithm uses) behind each credit card number.