Solved

Creating unique credit card-like numbers

Posted on 2004-04-20
2
182 Views
Last Modified: 2010-04-05
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.

Any ideas or links?
0
Comment
Question by:EddieShipman
2 Comments
 
LVL 26

Author Comment

by:EddieShipman
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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 118
Printing problem 2 102
Magic Software info 18 138
Base1 Encode/Decode 3 81
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question