Home » Articles » Understanding the Luhn Algorithm – How Credit Card Numbers are Made

Understanding the Luhn Algorithm – How Credit Card Numbers are Made

*Editorial Note: This content is not provided or commissioned by the credit card issuer. Any opinions, analyses, reviews or recommendations expressed in this article are those of the author’s alone, and may not have been reviewed, approved or otherwise endorsed by the credit card issuer. This site may be compensated through a credit card issuer partnership.

This article was last updated Oct 09, 2017, but some terms and conditions may have changed or are no longer available. For the most accurate and up to date information please consult the terms and conditions found on the issuer website.

Imagine what power you’d have if you knew how credit card numbers are generated to make them legitimate and functional. You could launch a global business manufacturing counterfeit cards (illegal of course) similar to creating counterfeit currency.  The problem of course is figuring out what numbers to create, and the Luhn algorithm makes certain that your business idea is destined to fail.

Introducing the Luhn Algorithm

I certainly don’t want some kid in a basement to cook up a card with my credit card account numbers on it and then go on a spree at the mall. The reason someone has not been able to pull off that kind of get-rich-quick scheme is because of something known as the Luhn algorithm. This is a mathematical formula that when applied generates credit card numbers that are genuinely unique and virtually impossible to duplicate, guess, or otherwise invent.

Hans Luhn was an IBM employee who, back in the 1950s, came up with an algorithm to verify a string of unique numbers. Today his method – known as the Luhn algorithm – is used by all credit card companies as a way to create distinct card account numbers. That way there is no possibility, for example, that your card number will turn out to be the same as mine. That would create chaos, naturally, while also giving criminals a way to exploit the entire credit card account numbering system.

Why the Algorithm is So Vital

In this era when plastic represents more than just convenience, there is a serious need for the protection of credit card numbers. Credit card numbers have been a target of choice for many thieves and hackers. One of my card numbers was stolen once and used to pay for travel all over California and Nevada. Meanwhile I was traveling across England and France. Since I have not figured out how to clone myself the itineraries looked rather suspicious on my monthly statement. So the Luhn algorithm is in many ways the Holy Grail of passwords. It cannot save you from losing your card or having someone working in a restaurant copy it down and use it to buy stuff. But it can guard the numbers in way that allows each of us to have our own personal and private account.

Applying the Luhn algorithm can be a time-intensive process but it breaks down to a few simple steps.  Grab any credit card from your wallet, start with the second digit from the right and follow the instructions below:

If your final number is divisible by ten, congratulations, you have a real credit card. If it's not, you best double check your math because it should be.

Most credit card numbers start with six digits that identify the card issuing company. Then there are 10 digits more that can be arranged in ten billion different combinations. If the last one in the sequence does not compute correctly after applying the Luhn algorithm to the preceding digits then the card number is a fake and will not work. So one company can safely and securely issue about one billion individual cards using the algorithm.

The Challenge of Cracking the Code

The formula has held up to the test of time and the pressures of the underworld. Despite tens of millions of attempts by hundreds of thousands of professional hackers, it remains the gatekeeper for the entire credit card industry. Without it you would not be able to securely use your card and the convenient world of plastic as we know it would experience a mega-meltdown.

Recommended Posts:

Read More

Survey: Generation X Couples Fight Most About Money

  Sometimes opposites attract, but when it comes to money and relationships, that can create tension and arguments. The good news is that conflict decreases as we age, according to a survey by CompareCards.com, a subsidiary of LendingTree. Key survey findings Arguments over money decrease with age. Some 15 percent of all couples surveyed said […]

Read More

Read More

Top 10 Credit Cards for Excellent Credit

An excellent credit score can help you qualify for the best credit cards on the market. The effort you put in to attain excellent credit won’t go unnoticed and banks will be vying for your business with unique card offers. However, with great rewards also come some additional costs, typically in the form of higher […]

Read More

Read More

Discover Vs. Visa

Have you ever wondered if there’s really a big difference between Visa and Discover? You’ll notice both companies’ logos on the front of credit cards and at cash registers around the world — but what sets them apart? In this review we’ll dive into the history of both companies, the benefits associated with credit cards […]

Read More