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

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 Feb 24, 2012, 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

Year-end Personal Finance Checklist

With Christmas and New Years behind us, now is a great time to review your finances and make sure everything is in order. You don’t have to spend all weekend balancing your checkbook or number-crunching your budget, but doing a quick check-up of your financial health can help you focused and bring peace of mind […]

Read More

November 18, 2013

Read More

Credit Cards for Pet Expenses

Pet ownership has tripled since the 1970’s with an estimated 83.3 million owned dogs and 95.6 million owned cats. Pet ownership has been on the rise due to several factors such as animal abuse awareness campaigns and the promotion of “no-kill” shelters. Pet ownership has been linked to a healthier lifestyle by easing loneliness, reducing […]

Read More

May 14, 2015

Read More

Don’t Regret It, Shred It!

Identity theft costs Americans nearly $2 billion a year. If your identity is stolen, dozens of fraudulent credit cards may be applied for and issued in your name before you even realize you’ve been harmed. Then those can be sold to the highest bidder through criminal networks that extend around the globe. So, what do […]

Read More

August 19, 2013