# Creating unique credit card-like numbers

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.

LVL 26
###### Who is Participating?

Commented:
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

All-around developerAuthor Commented:
No, I am not generating fake credit card numbers. This is for product registration and, no, I do not want to use GUIDs.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.