Solved

# Creating unique credit card-like numbers

Posted on 2004-04-20
179 Views
I need to CREATE a number like a credit card number that will also use the same MOD10 Checksum algorithm
that a credit card uses. I have the validation routines but can't figure out how to CREATE the numbers.

0
Question by:EddieShipman

LVL 26

Author Comment

ID: 10872464
No, I am not generating fake credit card numbers. This is for product registration and, no, I do not want to use GUIDs.
0

LVL 17

Accepted Solution

mokule earned 125 total points
ID: 10873513
You must generate 15 digit number and this function will generate the 16-th rightmost digit.

function TForm1.Generate(str: string): string;
var
i: integer;
len: integer;
su: integer;
dig: integer;
begin
len := Length(str);
su := 0;
for i := 0 to len-1 do
begin
dig := Ord(str[len-i]) - Ord('0');
if (i mod 2) = 1 then
su := su + dig
else if dig < 5 then
su := su + 2 * dig
else
su := su + 1 + 2 * dig - 10;
end;
if su mod 10 = 0 then
Result := str + '0'
else
Result := str + Char(Ord('0') + 10 - su mod 10);
end;
0

## Featured Post

### Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.