美文网首页
js生成随机密码

js生成随机密码

作者: power__c081 | 来源:发表于2017-10-20 16:56 被阅读0次

    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;

    }

    相关文章

      网友评论

          本文标题:js生成随机密码

          本文链接:https://www.haomeiwen.com/subject/ummvuxtx.html