JS生成随机密码字符串

靖西网牛牛动态域名 2016-07-22
  1. function randomString(len) {
  2.   len = len || 32;
  3.   var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  4.   var maxPos = $chars.length;
  5.   var pwd = '';
  6.   for (i = 0; i < len; i++) {
  7.     pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  8.   }
  9.   return pwd;
  10. }
  11. document.write(randomString(32));


浏览838859 / 回复2
举报内容

竖线全部回复

2016-07-22
  1. <script> function randomString(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; } function setpassid(len,divid) {     len = len || 32;     $(divid).val(randomString(len)); } </script> <span onclick="setpassid(20,divid)">[随机字符]</span>
回复
1
返回 [发帖] 发回复:评论……

+
提交评论