?
Solved

Creating unique credit card-like numbers

Posted on 2004-04-20
2
Medium Priority
?
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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