Newsgroups: | sci.crypt |
Path: | icdoc!dds |
From: | dds@doc.ic.ac.uk (Diomidis Spinellis) |
Subject: | Re: Information Request |
Nntp-Posting-Host: | dirty.doc.ic.ac.uk |
Message-ID: | <1992Jan7.155756.3444@doc.ic.ac.uk> |
Organization: | Dept. of Computing, Imperial College, London, England |
Keywords: | Checksums,Authentication Signatures, Source code |
Date: | Tue, 7 Jan 1992 15:57:56 GMT |
References: | <2600@manta.NOSC.MIL> |
Lines: | 36 |
Content-Length: | 1348 |
In article <2600@manta.NOSC.MIL> gcole@manta.NOSC.MIL (Guy Cole) writes:
>
> I am looking for any pointers to information on the algorithms used
>to verify credit cards (and similar authentication schemes). For example,
>I know that the last digit on most credit cards is typically a checksum.
>What is this method actually called? Is is a commercial standard?
It is called Luhn's formula. The last digit is the ten's complement of
the modulo sum of the other digits where each other digit is doubled.
There is an international standard specifying the number codes, and
their allocation. The following routine will calculate the checksum
number:
/*
* Return last digit of a bank card (e.g. credit card)
* Receives all the digits, but the last one as input
* By Diomidis Spinellis <dds@doc.ic.ac.uk>
*/
int
bank(u)
char *u;
{
register i, s = 0;
int l, t;
l = strlen(u);
for(i = 0; i < l ; i++) {
t = (u[l - i - 1] - '0') * (1 + ((i + 1) % 2));
s += t < 10 ? t : t - 9;
}
return 10 - s % 10;
}
--
Diomidis Spinellis Internet: dds@doc.ic.ac.uk
Department of Computing UUCP: ...!ukc!icdoc!dds
Imperial College, London SW7 #include "/dev/tty"
Newsgroup sci.crypt contents
Newsgroup list
Diomidis Spinellis home page
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.