Mod 10 credit card validation
Today I learned the magic formula that makes any valid credit card number evenly divisible by 10. There are plenty of other sources of this information on the web, but many are confusing or potentially wrong. This, among other things, is used to validate numbers before sending them off to be processed.
I have verified this works with visa, mastercard, amex and it should work with discover and jcp too.
I did some searching for a fake credit card numbers that validate which probably put on some goverment watch lists somewhere. Via a blog post by the Rimm-Kaufman Group I found this Amex number which should demonstrate this method.
371449635398431
Step 1. Reverse the number
3 7 1 4 4 9 6 3 5 3 9 8 4 3 1 becomes
1 3 4 8 9 3 5 3 6 9 4 4 1 7 3
Step 2. Double every second number
1 3 4 8 9 3 5 3 6 9 4 4 1 7 3 becomes
1 6 4 16 9 6 5 6 6 18 4 8 1 14 3
Step 3. Any 2 digit sums from step 2 have their component number added together. In other words 14 is 1 + 4 = 5
1 6 4 16 9 6 5 6 6 18 4 8 1 14 3 becomes
1 6 4 7 9 6 5 6 6 9 4 8 1 5 3
Step 4. Add all the numbers together
1 6 4 7 9 6 5 6 6 9 4 8 1 5 3 becomes
1+6+4+7+9+6+5+6+6+9+4+8+1+5+3 which is
80
Step 5. Is the sum evenly divisible by 10? If so then you can be 1 step closer to sure that the credit card number is valid. There are also other things you have to check that are card provider specific. For example, all visa number start with 4 and are either 13 or 16 digits long.