This JS code according to the credit card number generated rules randomly generated credit card number, can be verified, only for learning reference, please do not use for illegal purposes, or the consequences of conceit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 87 88 89 90 91 92 93 94 |
var visaprefixlist = new Array ("4539", "4556", "4916", "4532", "4929", "40240071", "44") 85 "," 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 jcbprefixlist = new Array ("35"); 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) Retu RN Revstr; }/* ' prefix ' is the "start of" CC number as a string, any number of digits. ' Length ' is the length of the CC number to generate. typically or * * function completed_number (prefix, length) {var ccnumber = prefix;//generate digits while (ccnumb Er.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 < Reversedccnumberstring.length i++) {Reversedccnumber[i] = parseint (Reversedccnumberstring.charat ( i)); //calculate sum var sum = 0; var pos = 0; 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 var checkdigit = ((Math.floor (SUM/10) +1) *10-sum)%10; Ccnumber + = Checkdigit; return ccnumber; function Credit_card_number (prefixlist, length, howmany) {var result = new Array (); for (var i = 0; i < Howmany; i++ {var randomarrayindex = Math.floor (Math.random () * prefixlist.length); var ccnumber = prefixlist[Randomarrayindex]; r Esult.push (Completed_number (ccnumber, length)); return result; } |
Call Method:
Save the above code as a gencc.js file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 |
|