生成31位随机字符串的方法
作者:互联网
function randomString(len) {
len = len || 31;
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
var maxPos = $chars.length;
var pwd = '';
for (i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
document.write(randomString(31));
标签:31,len,var,pwd,随机,字符串,randomString,chars 来源: https://www.cnblogs.com/shangjun6/p/11915657.html