Do project to use this thing, so Baidu its method, record it. Code to serve.
Randomly generate n-bit numbers:
function randomnum (n) { //N is the number of digits generated by var t= '; for (var i=0;i<n;i++) { T+=math.floor (math.random () *10); } return t; } Alert (Randomnum (6));
Randomly generate N-letters
function getrandomstring (len) { var// default removes easily confusing characters ooll,9gq,vv,uu,i1 var maxpos = chars.length; var pwd = '; for (i = 0; i < len; i++) { + = Chars.charat (Math.floor (Math.random () * maxpos)) ; } return pwd; } Alert (getrandomstring (3));
Chars.charat is the character that selects the number of index numbers. Math.floor () rounding down Math.random () takes 0-1 random numbers
The climax comes, the letters plus the digital stitching is
var pwd = getrandomstring (3); var t = randomnum (6); var fdnm = pwd + t;
Randomly generated keys