Generating Test Credit Card Numbers
Credit card numbers (CCN) or primary account numbers (PAN) are the string of digits on the front of most credit cards. The major cards here in the United States are 16 digits long. While they appear to be random, valid CCNs are based on a published calculation formula.
The first digits of a credit card are unique for each credit card issuing institution such as American Express or Visa. This is called the issuer identification number (IIN). The last digit of a credit card is the “check digit,” which is calculated by the Luhn Algorithm. Thus, the format is IIN–Random Digits–Check Digit.
IRI has created a new library function for RowGen users who want to generate their own credit card numbers to use in test database, file, and/or report targets. To use this function, call the special RowGen test data generation function, ccn_gen in the input field. The format for the call is: ccn_gen(“Card_Name, “Separator”).
- “Card_Name” is where you enter the type of card you wish to generate. To generate all Discover cards numbers, type “DISCOVER_CARD” there. Or for a variety of card types, simply type “ANY”, and it will randomly generate differing card types. The function’s available card-type names are:
- “DISCOVER_CARD”
- “MASTER_CARD”
- “VISA”
- “AMERICAN_EXPRESS”
- “ANY”
- “Separator” is the character you specify to delimit the digit values in the card display. Any character will do, such as “-“, “_”, “=”, “@”. The only exception is “0”, which will have the same effect as leaving the field blank (“”) and creating card numbers with no separators. If you call the function without any parameters, “ccn_gen()”, it will generate with random card types and no separators.
The following job script demonstrates the function in a RowGen specification (.scl) file, which you can create and edit by hand or automatically in the IRI Workbench GUI for RowGen.
/library="libcsccn.dll" /INFILE=random /PROCESS=RANDOM /INCOLLECT=1 /FIELD=(CCN=ccn_gen("ANY","-"), POSITION=1, SIZE=20) /REPORT /OUTFILE=CCN.set /PROCESS=RECORD /FIELD=(CCN, POSITION=1, SIZE=20)
The output is 6011-3517-0926-9741 because /INCOLLECT was only set to 1.
Any number of records can be generated from this function, and output with other test data values to target files, ODBC-connected tables, or custom-formatted reports. Other fields can still be randomly generated (and/or randomly selected from real sources) in any way you wish. If you are interested in using this function in RowGen, please contact your IRI representative.