Solved

Creating unique credit card-like numbers

Posted on 2004-04-20
2
179 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now