Results 1 to 5 of 5
  1. #1
    cruizrisner's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    381
    Reputation
    22
    Thanks
    48

    PHP CC generator

    Code:
    <?php
    /*
    PHP credit card number generator
    */
    
    $visaPrefixList[] =  "4539";
    $visaPrefixList[] =  "4556";
    $visaPrefixList[] =  "4916";
    $visaPrefixList[] =  "4532";
    $visaPrefixList[] =  "4929";
    $visaPrefixList[] =  "40240071";
    $visaPrefixList[] =  "4485";
    $visaPrefixList[] =  "4716";
    $visaPrefixList[] =  "4";
    
    $mastercardPrefixList[] =  "51";
    $mastercardPrefixList[] =  "52";
    $mastercardPrefixList[] =  "53";
    $mastercardPrefixList[] =  "54";
    $mastercardPrefixList[] =  "55";
    
    $amexPrefixList[] =  "34";
    $amexPrefixList[] =  "37";
    
    $discoverPrefixList[] = "6011";
    
    $dinersPrefixList[] =  "300";
    $dinersPrefixList[] =  "301";
    $dinersPrefixList[] =  "302";
    $dinersPrefixList[] =  "303";
    $dinersPrefixList[] =  "36";
    $dinersPrefixList[] =  "38";
    
    $enRoutePrefixList[] =  "2014";
    $enRoutePrefixList[] =  "2149";
    
    $jcbPrefixList16[] =  "3088";
    $jcbPrefixList16[] =  "3096";
    $jcbPrefixList16[] =  "3112";
    $jcbPrefixList16[] =  "3158";
    $jcbPrefixList16[] =  "3337";
    $jcbPrefixList16[] =  "3528";
    
    $jcbPrefixList15[] = "2100";
    $jcbPrefixList15[] = "1800";
    
    $voyagerPrefixList[] = "8699";
    
    /*
    '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) {
    
        $ccnumber = $prefix;
    
        # generate digits
    
        while ( strlen($ccnumber) < ($length - 1) ) {
            $ccnumber .= rand(0,9);
        }
    
        # Calculate sum
    
        $sum = 0;
        $pos = 0;
    
        $reversedCCnumber = strrev( $ccnumber );
    
        while ( $pos < $length - 1 ) {
    
            $odd = $reversedCCnumber[ $pos ] * 2;
            if ( $odd > 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[] = "<div class='creditCardNumbers'>";
        $result[] = "<h3>$title</h3>";
        $result[] = implode('<br />', $numbers);
        $result[]= '</div>';
    
        return implode('<br />', $result);
    }
    
    #
    # Main
    #
    
    echo "<div class='creditCardSet'>";
    $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 "</div>";
    
    echo "<div class='creditCardSet'>";
    $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 "</div>";
    
    # Minor cards
    
    echo "<div class='creditCardSet'>";
    $discover = credit_card_number($discoverPrefixList, 16, 3);
    echo output("Discover", $discover);
    
    $diners = credit_card_number($dinersPrefixList, 14, 3);
    echo output("Diners Club", $diners);
    echo "</div>";
    
    echo "<div class='creditCardSet'>";
    $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 "</div>";
    
    echo "<div class='creditCardSet'>";
    $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 "</div>";
    ?>

  2. #2
    Bryci's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    In your pants. /fmm
    Posts
    503
    Reputation
    -24
    Thanks
    19
    My Mood
    Amused
    Nice code. I'm guessing you based this on the Luhn algorithm system? :O

  3. #3
    cosconub's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in the programming section MPGH Cash: $90,000,000,000
    Posts
    372
    Reputation
    -4
    Thanks
    39
    My Mood
    Psychedelic
    nice i did mine in Java

  4. #4
    Alen's Avatar
    Join Date
    Oct 2007
    Gender
    male
    Location
    Liquid Generator
    Posts
    27,920
    Reputation
    2548
    Thanks
    4,224
    My Mood
    Fine
    Quote Originally Posted by cosconub View Post
    nice i did mine in Java
    Nice bump / necro.

  5. #5
    Archangel's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Between Both Worlds
    Posts
    8,866
    Reputation
    1021
    Thanks
    9,003
    My Mood
    Angelic
    bumped

    /closed

Similar Threads

  1. [MPGH] Forum Signiture Generator // In the making...
    By apitite.for.distruction in forum Art & Graphic Design
    Replies: 4
    Last Post: 10-19-2006, 02:02 PM
  2. leet speak generator
    By Duagang in forum General
    Replies: 2
    Last Post: 05-06-2006, 09:20 PM
  3. Random Integer Generator
    By SpiderByte in forum C++/C Programming
    Replies: 12
    Last Post: 02-19-2006, 04:46 AM
  4. Random Integer Generator
    By SpiderByte in forum Art & Graphic Design
    Replies: 6
    Last Post: 01-22-2006, 09:51 AM