function randomPassword(size){//size是生成随机密码的位数
var seed=new Array('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','0','1',
'2','3','4','5','6','7','8','9'
);//数组
var seedlength=seed.length;//数组长度
var createPassword='';
for(let i=0;i<size;i++){
var a=Math.floor(Math.random()*seedlength);
createPassword+=seed[a];
}
returncreatePassword;
}
网友评论