1/11/2008

CVV Numbers

CVVs, CVV2s, CVCs, and Indent CVCs are 3-digit Card Verification Values or Card Verification Codes that are all calculated using the same CVV algorithm. These values are required by payment systems such as Visa and MasterCard to authenticate their credit or debit cards. Different names are used to refer to the values depending on the particular payment system, the location of the value on the card, and the parameters passed to the CVV algorithm.

To calculate a 3-digit CVV, the CVV algorithm requires a Primary Account Number (PAN), a 4-digit Expiration Date, a 3-digit Service Code, and a pair of DES keys (CVKs).

Besides the obvious CVV variations provided by different PANs and expiration dates, most card issuers will use different CVKs for different batches of cards. Cards can be grouped by bank, by ATM network, or by other means of identifying a certain group of cards. Cards in the same batch will often use the same service code. This service code to the CVV algorithmis usually non-zero. One CVV variant, now commonly called CVV2 (Visa), or Indent CVC (MasterCard), uses '000' as the service code parameter to the CVV algorithm. Sometimes a card will have both a traditional CVV and a CVV2.

Another variation to the CVV algorithm can be introduced by changing the format of the expiration date. While the date is always the concatenation of the 2-digit month (MM) andlast 2 digits of the year (YY), it can be in either YYMM or MMYY formats. For instance, Visa CVV2s are usually calculated using the YYMM format.

Credit Card Generator

Credit card generator

There was a mistake in the Javascript credit card generator, meaning it would not work on MS Internet Explorer or Opera. This has now been fixed, and I have tested it successfully on:

  • Firefox 1.0.6
  • Konqueror 3.4.1
  • Internet Explorer 6.0
  • Opera 8.5.2

The archive now also includes an example on how to use the Javascript version (which seems the most popular).

Command line Python program, PHP script, and Javascript script to generate valid (MOD 10) credit card numbers. Usefull for testing e-commerce sites. (Note: You can't actually buy anything with these). Should run on any platform.

This generates 13 and 16 digit VISA, Mastercard, Amex, and a whole bunch of others.

If you just need a bunch of numbers use the online credit card number generator. That page is generated by an online version of this script.

Fro the Python script, you will need Phyton . Once you have installed Python and extracted gencc.py from the archive, type 'python gencc.py' on the command line.

To use the PHP or Javascript scripts, you'll need to know a little bit about PHP or Javascript. In each case there is a method you need to call.

The ZIP and TAR.GZ below contain all three versions: The Python, PHP and Javascript files.


save with : namefile.py



"""
gencc: A simple program to generate credit card numbers that pass the MOD 10 check
(Luhn formula).
Usefull for testing e-commerce sites during development.

Copyright 2003 Graham King

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""

from random import Random
import sys
import copy

visaPrefixList = [ ['4', '5', '3', '9'],
['4', '5', '5', '6'],
['4', '9', '1', '6'],
['4', '5', '3', '2'],
['4', '9', '2', '9'],
['4', '0', '2', '4', '0', '0', '7', '1'],
['4', '4', '8', '6'],
['4', '7', '1', '6'],
['4'] ]

mastercardPrefixList = [ ['5', '1'],
['5', '2'],
['5', '3'],
['5', '4'],
['5', '5'] ]

amexPrefixList = [ ['3', '4'],
['3', '7'] ]

discoverPrefixList = [ ['6', '0', '1', '1'] ]

dinersPrefixList = [ ['3', '0', '0'],
['3', '0', '1'],
['3', '0', '2'],
['3', '0', '3'],
['3', '6'],
['3', '8'] ]

enRoutePrefixList = [ ['2', '0', '1', '4'],
['2', '1', '4', '9'] ]

jcbPrefixList16 = [ ['3', '0', '8', '8'],
['3', '0', '9', '6'],
['3', '1', '1', '2'],
['3', '1', '5', '8'],
['3', '3', '3', '7'],
['3', '5', '2', '8'] ]

jcbPrefixList15 = [ ['2', '1', '0', '0'],
['1', '8', '0', '0'] ]

voyagerPrefixList = [ ['8', '6', '9', '9'] ]


"""
'prefix' is the start of the CC number as a string, any number of digits.
'length' is the length of the CC number to generate. Typically 13 or 16
"""
def completed_number(prefix, length):

ccnumber = prefix

# generate digits

while len(ccnumber) < (length - 1): digit = generator.choice(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']) ccnumber.append(digit) # Calculate sum sum = 0 pos = 0 reversedCCnumber = [] reversedCCnumber.extend(ccnumber) reversedCCnumber.reverse() while pos < odd =" int("> 9:
odd -= 9

sum += odd

if pos != (length - 2):

sum += int( reversedCCnumber[pos+1] )

pos += 2

# Calculate check digit

checkdigit = ((sum / 10 + 1) * 10 - sum) % 10

ccnumber.append( str(checkdigit) )

return ''.join(ccnumber)

def credit_card_number(generator, prefixList, length, howMany):

result = []

for i in range(howMany):

ccnumber = copy.copy( generator.choice(prefixList) )

result.append( completed_number(ccnumber, length) )

return result

def output(title, numbers):

result = []
result.append(title)
result.append( '-' * len(title) )
result.append( '\n'.join(numbers) )
result.append( '' )

return '\n'.join(result)

#
# Main
#

generator = Random()
generator.seed() # Seed from current time

print "darkcoding credit card generator "
print

mastercard = credit_card_number(generator, mastercardPrefixList, 16, 10)
print output("Mastercard", mastercard)

visa16 = credit_card_number(generator, visaPrefixList, 16, 10)
print output("VISA 16 digit", visa16)

visa13 = credit_card_number(generator, visaPrefixList, 13, 5)
print output("VISA 13 digit", visa13)

amex = credit_card_number(generator, amexPrefixList, 15, 5)
print output("American Express", amex)

# Minor cards

discover = credit_card_number(generator, discoverPrefixList, 16, 3)
print output("Discover", discover)

diners = credit_card_number(generator, dinersPrefixList, 14, 3)
print output("Diners Club / Carte Blanche", diners)

enRoute = credit_card_number(generator, enRoutePrefixList, 15, 3)
print output("enRoute", enRoute)

jcb15 = credit_card_number(generator, jcbPrefixList15, 15, 3)
print output("JCB 15 digit", jcb15)

jcb16 = credit_card_number(generator, jcbPrefixList16, 16, 3)
print output("JCB 16 digit", jcb16)

voyager = credit_card_number(generator, voyagerPrefixList, 15, 3)
print output("Voyager", voyager)

save with: filename.php

9 ) {
$odd -= 9;
}

$sum += $odd;

if ( $pos != ($length - 2) ) {

$sum += $reversedCCnumber[ $pos +1 ];
}
$pos += 2;
}

# Calculate check digit

$checkdigit = (( floor($sum/10) + 1) * 10 - $sum) % 10;
$ccnumber .= $checkdigit;

return $ccnumber;
}

function credit_card_number($prefixList, $length, $howMany) {

for ($i = 0; $i < $howMany; $i++) { $ccnumber = $prefixList[ array_rand($prefixList) ]; $result[] = completed_number($ccnumber, $length); } return $result; } function output($title, $numbers) { $result[] = "
";
$result[] = "

$title

";
$result[] = implode('
', $numbers);
$result[]= '
';

return implode('
', $result);
}

#
# Main
#

echo "
";
$mastercard = credit_card_number($mastercardPrefixList, 16, 10);
echo output("Mastercard", $mastercard);

$visa16 = credit_card_number($visaPrefixList, 16, 10);
echo output("VISA 16 digit", $visa16);
echo "
";

echo "
";
$visa13 = credit_card_number($visaPrefixList, 13, 5);
echo output("VISA 13 digit", $visa13);

$amex = credit_card_number($amexPrefixList, 15, 5);
echo output("American Express", $amex);
echo "
";

# Minor cards

echo "
";
$discover = credit_card_number($discoverPrefixList, 16, 3);
echo output("Discover", $discover);

$diners = credit_card_number($dinersPrefixList, 14, 3);
echo output("Diners Club", $diners);
echo "
";

echo "
";
$enRoute = credit_card_number($enRoutePrefixList, 15, 3);
echo output("enRoute", $enRoute);

$jcb15 = credit_card_number($jcbPrefixList15, 15, 3);
echo output("JCB 15 digit", $jcb15);
echo "
";

echo "
";
$jcb16 = credit_card_number($jcbPrefixList16, 16, 3);
echo output("JCB 16 digit", $jcb16);

$voyager = credit_card_number($voyagerPrefixList, 15, 3);
echo output("Voyager", $voyager);
echo "
";
?>

save with : namefile.js


var visaPrefixList = new Array(
"4539",
"4556",
"4916",
"4532",
"4929",
"40240071",
"4485",
"4716",
"4"
);

var mastercardPrefixList = new Array(
"51",
"52",
"53",
"54",
"55"
);

var amexPrefixList = new Array(
"34",
"37"
);

var discoverPrefixList = new Array("6011");

var dinersPrefixList = new Array(
"300",
"301",
"302",
"303",
"36",
"38"
);

var enRoutePrefixList = new Array(
"2014",
"2149"
);

var jcbPrefixList16 = new Array(
"3088",
"3096",
"3112",
"3158",
"3337",
"3528"
);

var jcbPrefixList15 = new Array(
"2100",
"1800"
);

var voyagerPrefixList = new Array("8699");


function strrev(str) {
if (!str) return '';
var revstr='';
for (i = str.length-1; i>=0; i--)
revstr+=str.charAt(i)
return revstr;
}

/*
'prefix' is the start of the CC number as a string, any number of digits.
'length' is the length of the CC number to generate. Typically 13 or 16
*/
function completed_number(prefix, length) {

var ccnumber = prefix;

// generate digits

while ( ccnumber.length < (length - 1) ) { ccnumber += Math.floor(Math.random()*10); } // reverse number and convert to int var reversedCCnumberString = strrev( ccnumber ); var reversedCCnumber = new Array(); for ( var i=0; i < sum =" 0;" pos =" 0;" odd =" reversedCCnumber["> 9 ) {
odd -= 9;
}

sum += odd;

if ( pos != (length - 2)