From: "Mark McCulligh" <[EMAIL PROTECTED]>
Sent: Tuesday, July 23, 2002 8:47 PM
Subject: [PHP] Re: Credit card checks?


> You could use an algorithms called mod10.

Mod 10 catches keying errors.  It's use is to prevent digits from being
swapped.   So if you key 133791 instead of 137391, the mod 10 will catch it.
It works for all single keying errors except 0 and 9, since reversing those
two numbers will result in the same check digit.  It fails to catch multiple
keying errors, so if more than one pair of digits is swapped, or if the
swapped digits are not contiguous, there is a likely chance of validating
fine.

It's actually very useful in numeric keys to dbs such as address book
entries and skus.  If you don't use an auto-increment, and instead maintain
the next numbers yourself, you can calc and append the check digit to the
next number.  You end up with a db whose keys are all based on Mod 10, so if
someone does a single keying error, it won't be in the db.  In other words,
you really only need to calc the Mod 10 when doing the insert, because
invalid keys won't be in the db, and thus won't be found.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to