js生成随机数的方法
文章目录
function randomString(len=32) {
let chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
let maxPos = chars.length;
let pwd = '';
for (i = 0; i < len; i++) {
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论