JS_0012:JS从一个有规则的字符串中随机选择一个字符再循环生成一个新的无规则的字符串

1,

//生成自动名
function random_string(len) {
    len = len || 32;
    var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
    var maxPos = chars.length;
    var pwd = '';
    for (i = 0; i < len; i++) {
        pwd += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return pwd;
}
琥珀君的博客
原文地址:https://www.cnblogs.com/eliteboy/p/13234369.html