The credit card code

by Khürt on July 26, 2006

in How To

Credit cards have a hash digit that is used to validate whether a credit card number is valid or not. The algorithm for calculating this digit is known as the LUHN formula, based on ANSI X4.13. To calculate whether a credit card number is valid, follow these three steps:
Starting with the second digit on the right, multiply every other digit by two. If the result of any doubling is greater than 10 (e.g., 8 + 8 = 16), add the digits of this result. Add all of the doubled digits.

Add all other digits, with the exception of the last digit (the checksum), to this total.

The difference between the sum and the next multiple of 10 is the check digit.

For example, the correct hash digit for credit card number 5012 3456 7890 123X is 6.

Note: Until recently all credit card companies were using the same algorithm. Recent advances in credit card fraud have caused the credit card companies to pursue further measures of validating credit cards such as the 3-digit number found on the back of your credit card.” — From CISSP course

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
GAuthor: Khürt
I'm a husband, a father to two very smart kids, an information security manager and a web developer. I'm a Mac geek who loves photography, hefe-weisse ale and Ethiopian coffee. I'm @khurtwilliams on twitter.

{ 1 comment }

Talha July 26, 2006 at 1:31 pm

cool, i like the info

Comments on this entry are closed.

blog comments powered by Disqus

Previous post:

Next post: