584 words
3 minutes
Validating Credit Card Numbers
This post was translated from the Japanese original with AI. Read the original (Japanese)

Introduction#

Credit card numbers are something we see all the time, but there are all sorts of rules and security measures behind them too. In this post I’ll go over those.

Overview of the number#

First, how a credit card number is structured: credit card numbers are defined in ISO/IEC 7812, and consist of a 6-digit BIN (Bank Identification Number) or IIN (Issuer Identification Number) plus the remaining digits, which are decided by the issuer.

NOTE

Update (October 2026): The ISO/IEC 7812-1:2017 revision extended the IIN to 8 digits, and since April 2022 the card networks only assign new BINs as 8 digits (existing 6-digit BINs remain in use). The discussion below assumes 6 digits, so keep in mind that if you can pin down an 8-digit BIN, there are two fewer unknown digits. ISO/IEC 7812

About BIN and IIN#

The BIN/IIN is itself made up of multiple parts. The first digit is called the MII (Major Industry Identifier) and indicates the industry the card is used in; the mapping is as follows.

MII valueIndustry
0Reserved by ISO
1Airlines
2Airlines / other future industry assignments
3Travel & entertainment / banking & financial
4Banking & financial
5Banking & financial
6Merchandising / banking & financial
7Petroleum / other future industry assignments
8Healthcare / medical / telecommunications / other future industry assignments
9Assignable by national standards bodies

And below is a list of major BINs, past and present.

Card typePrefixLengthValidation
American Express34, 3715Luhn algorithm
China UnionPay622126-622925, 624-626, 6282-628816None
Diners Club International300-303574, 3095, 36, 38-3914Luhn algorithm
Discover Card60110, 60112-60114, 601174-601179, 601186-601199, 644-649, 6516Luhn algorithm
JCB3528-358916Luhn algorithm
MasterCard510000 - 559999, 222100 - 27209916Luhn algorithm
UATP115Unknown
Visa413, 16Luhn algorithm

About the check digit#

Credit card numbers use the Luhn algorithm. My guess is that its main purposes are to avoid issuing numbers sequentially and to prevent someone else’s card from being charged because of a typo. However, since it can be calculated, it isn’t meant to stop malicious payments.

Validation from a security perspective#

Based on the rules above, here’s what I tested.

Overview of the test#

These days services like Apple Pay display the last 4 digits of the card number for reference, and in Apple Pay’s case you can identify the issuer to some extent from the card design, so I tested whether the card number could be guessed from that.

Identifying the BIN/IIN#

First, I tried identifying the BIN from the card design. BINs aren’t officially published, but you can look them up on sites like the one below. Some card companies have an enormous number of registered BINs, so at this point the issuers whose card numbers could be pinned down are already limited, but from here on I’ll assume the BIN has been identified. BIN search

Identifying the card number#

I’ll proceed assuming the BIN has been identified. At this point you know the 6-digit BIN plus the last 4 digits. I then computed every number that satisfies the Luhn algorithm (for 16 digits this time). I checked it on the site below, and there were well over 100 candidates, so identifying the number was impossible. credit card number generator

Summary#

As shown above, the result is that identifying a card number from screenshots, receipt photos, and the like is practically impossible. On top of that, mandatory security codes and the rollout of 3D Secure have been progressing in recent years, so even if a number were cracked, realistically there’d be no merchant where you could actually make a payment with it.

NOTE

Update (October 2026): The Credit Card Security Guidelines [version 5.0] (Japan) require, in principle, all e-commerce merchants to adopt EMV 3-D Secure by the end of March 2025. Introduction of the authentication service for card payments (EMV 3-D Secure) | JCB (Japanese)

Validating Credit Card Numbers
https://doany.io/en/posts/number/
Author
丸山 竜輝
Published at
2018-07-27
License
CC BY-NC-SA 4.0
If a post helped you out, your support keeps me going.
Support me on Ko-fi