What algorithm to use to calculate a check digit for a list of digits?
The length of the list is between 8 and 12 digits.
views:
566answers:
5
+7
A:
The Luhn algorithm is good enough for the credit card industry...
RichieHindle
2009-07-08 21:55:57
Luhn algorithm is way to weak, try swapping the first digit with the last digit - ooops, valid!
Alix Axel
2009-09-12 15:31:08
+5
A:
As RichieHindle points out, the Luhn algorithm is pretty good. It will detect (but not correct) any one error or transposition (except a transposition of 0 and 9).
You could also consider the algorithm for ISBN check digits, although for old-style ISBN, the check digit is sometimes "X", which may be a problem for you if you're using integer fields. New-style ISBN doesn't seem to have that problem. Wikipedia doesn't go in to the theoretical properties of the system, but I remember studying ISBN numbers in my coding theory course long ago, so I think they are pretty good :-)
John Fouhy
2009-07-08 22:18:12