Sunday, August 1, 2010

The Secret Code Of Credit Cards

Have you ever given any thought at all to your credit card number?  I hadn't until I learned about the Luhn algorithm.  Now I know that the numbers on my cards aren't just a series of random numerals.  They all have a meaning.

 The Luhn algorithm (or formula) was created in 1954 by Hans Peter Luhn, an IBM scientist.  When a card number is generated using Luhn's algorithm, various combinations of the digits on the card must add up to a number that is divisible by 10. For this reason, Luhn's formula is also referred to as modulus 10, or mod 10 for short.

The vast majority of credit card numbers have 15 or 16 digits. On a 16-digit Visa, MasterCard or Discover card, the first six numerals are known as the Issuer Identification Number (IIN) which identify the card issuer, and the next nine numerals are the card account number. (American Express uses an eight-digit account number, so their numbers are only 15 digits.)  The last digit in the number is a check digit. If you change or transpose any digits in a number, the Luhn formula will catch it.

I wanted to try out the formula, but I didn't want to use my real number.   I Goggled "credit card number generator", clicked on the first result, chose a random MasterCard number, and followed these steps:

The number I started with was
  • I removed the non numeric characters (dashes), and reversed the string:
4 8 8 0 8 1 5 3 7 9 0 1 6 5 2 6
  • Starting with the second digit, I doubled every other number (in red, to make it easier).
4 8 8 0 8 1 5 3 7 9 0 1 6 5 2 6
4 16 8 0 8 2 5 6 7 18 0 2 6 10 2 12
  • I took the sum of every digit. 

  • The last step is to divide the total by 10. If the remainder is 0 then the number is valid.
70 / 10 = 7 with no remainder 

4880-8153-7901-6526 would be a valid Master Card number!


  1. That's totally cool! I always thought there was some reason for the numbers...and thought it strange that some of the numbers on both my credit cards and drivers license had significant date numbers on them. I wonder what they might have for using numerology?

  2. Wow- I've learnt something new today! Thanks :-)

  3. This comment has been removed by a blog administrator.

  4. I guess you could say it's the DaVisa Code.

  5. maggie's garden--How interesting that some of the numbers on your cards have personal meaning for you.

    DragonflyLanternshop-You're welcome.

    Dawn--Where were you when I needed a snappy title for this post :-)

  6. Wow. Who knew? Method to the madness. :-)