: >can someone explain a mod10 validation. May be simple, but I've

: >never heard of it.

: >--

: >Bill Rice

Newsgroups: comp.lang.basic.visual.misc

Subject: Re: CORRECTION... credit card #'s - cc.txt [1/1]

Date: 25 May 1995 13:02:11 GMT

Hello Everyone:

I typed the previously posted algorithm from memory... sorry for

the mistakes in it.

What we're interested in is the Luhn code for the credit card. This

is what's used for validation...

This is how the Luhn code is calculated:

1) Double the value of alternate digits, starting with the rightmost (15th)

digit. If this doubling results in a two-digit number, add each digit

together to derive a single digit (eg 6 * 2 = '12'; '12' = 1 + 2 = '3').

2) Add the individual digits derived in step 1 to the remaining unaffected

digits in the original number.

3) If the total obtained in step 2 ends in zero (eg 20, 30, etc.) then the

Luhn code is '0'. If not subtract the total obtained in step 2 from the next

highest number ending in zero (ten's compliment of the low order digit). The

result is the Luhn code. The resulting Luhn code is then compared to the last

digit (16th or check digit) in the original field of data. If it matches,

then the number is valid, if not then the number is invalid.

Example:

641205 00234 0106 4

Double alternate digits starting from righmost (non check digit):

Order here is left to right:

6 *2 = 12 sum two digit numbers: 1 + 2 = 3

1 *2 = 2

0 *2 = 0

0 *2 = 0

2 *2 = 4

4 *2 = 8

1 *2 = 2

6 *2 = 12 sum two digit numbers: 1 + 2 = 3

Add the results to those remaining from the original number:

3 + 4 + 2 + 2 + 0 + 5 + 0 + 0 + 4 + 3 + 8 + 0 + 2 + 0 + 3 = 36

The next highest number ending in zero is '40'. 40 - 36 = 4

(ie Ten's compliment of 6 is 4). '4' is the Luhn code value and it matches

the check digit of the original number so the number is considered to be

valid.

Hope this clears things up.

Phil

--

GCS/E d(++) H s+: g? !p+ !au a- w+ v- C+++ U++ P+ N+++ y?

E--- W+ !M V -po+ Y !tv b+++ D++ B-- e* u+ h+ f !r n----

--

GCS/E d(++) H s+: g? !p+ !au a- w+ v- C+++ U++ P+ N+++ y?

E--- W+ !M V -po+ Y !tv b+++ D++ B-- e* u+ h+ f !r n----