js生成随机密码,密码位数自定
话不多说,上代码
function pb(size){
var seed = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','p','Q','r','s','t','u','v','w','x','y','z','2','3','4','5','6','7','8','9'];// 密码源数组
var n='';
for(var i=0;i<size;i++){
t=Math.round(Math.random()*(seed.length-1));
n+=seed[t];
}
return n;
}
document.write(pb(8));
var seed = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','p','Q','r','s','t','u','v','w','x','y','z','2','3','4','5','6','7','8','9'];// 密码源数组
var n='';
for(var i=0;i<size;i++){
t=Math.round(Math.random()*(seed.length-1));
n+=seed[t];
}
return n;
}
document.write(pb(8));