'*********************************************************************
*
'  Then I perform a Modulo 10 "Credit Card"-Style check on the Key
'Date: 1994-10-12,16:08
From: BILL MASELLA
To: DAVID PARKS
Subject: Mod10 - Product Digit Add
Flags:

DP=:-> Credit cards also use a modulus 10 check digit routine on them.
If t
  =:-> card number doesn't pass mod10 tthen you shouldn't allow it
either.


DP=:Back up.. I like what your saying, but I'm completely lost on what
  =:Modulus 10 means..  I'm by now means a programmer..  Could you
please
  =:explain what the mod10 is?  I would be extremely interested to
hear
  =:about it.

The actual process goes something like this...

Multiply each digit of the card holder number by its appropriate
number
in the weight series ...2121 starting at the far right digit of the
number.  Next take those products and add each of the digits together.
If the sum is divisible by 10 then the number has the correct check
digit on it.  If not the card is invalid....  Here is an example:

Card Number:        5  0  0  1  2  3  4  5  6  7  8  9  2  1  0  7
Weight Series:      2  1  2  1  2  1  2  1  2  1  2  1  2  1  2  1
-------------------------------------------------------------------
Products:          10  0  0  1  4  3  8  5  12 7  16 9  4  1  0  7
Add:               1+0+0 +0 +1 +4 +3 +8 +5+1+2+7+1+6+9 +4 +1 +0 +7 =
60

                   Is this sum EVENLY divisible by 10?  Yes! Card OK!

You need to pay close attention to starting the weighting with the
RIGHT
most digit first or it will not work.  On the shorter VISA numbers:

                         X  X  X  X     X  X  X     X  X  X     X  X
X
   Weighting would be:   1  2  1  2     1  2  1     2  1  2     1  2
1

Did this help?

You also know that the card numbers all have a certain length
requirement and that they all generally have a unique first couple of
digits which help you determine what card type you are looking at?

Visa all start with a 4   13 OR 16 digits long
MasterCard with a 5       16 digits long
Amex with a 37            15 digits long
Discover with a 60        16 digits long

When we test them we usually run them through a mask first to see if
it
is XX digits long and starts with the appropriate number.  If not we
never get to a check digit calculation.

======================================================================
==

Date: 1994-10-14,09:13
From: GREG HEWGILL
To: DAVID PARKS
Subject: Mod10 - Product Digit Add
Flags: Read

DP>Wow!  That has helped me out a lot!  I have tried calling visa, MC,
my
  >credit service, and so on for an explanation like that!  Thank You
very
  >very much!!!  (Trying to figure out how to program that for a basic
  >programmer like me will be a different story)  :)

Here's some code that will do that:

function JustDigits(cardnumber as string) as string
  dim numbers as string
  numbers = ""
  dim i as integer
  for i = 1 to len(cardnumber)
    if mid(cardnumber, i, 1) >= "0" and mid(cardnumber, i, 1) <= "9"
then
      numbers = numbers + mid(cardnumber, i, 1)
    end if
  next
  JustDigits = numbers
end function

function ValidCardNumber(cardnumber as string) as integer
  dim numbers as string
  numbers = JustDigits(cardnumber)
  dim sum as integer
  sum = 0
  dim m as integer
  m = 2
  dim i as integer
  for i = len(numbers)-1 to 1 step -1
    dim d as integer
    d = val(mid(numbers, i, 1)) * m
    if d >= 10 then
      d = (d mod 10) + 1
    end if
    sum = sum + d
    m = 3 - m
  next
  ValidCardNumber = (10 - (sum mod 10)) mod 10 = val(right(numbers,
1))
end function

The ValidCardNumber function will return whether it thinks the card
number is valid or not.  Hope this helps.

Greg
MSI


'******************************************************************
