jquery 或 javascript 密码生成器,至少有一个大写和一个数字 [英] jquery or javascript password generator with at least a capital and a number
本文介绍了jquery 或 javascript 密码生成器,至少有一个大写和一个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何修改这些示例之一,以在密码中至少包含一个大写字母和一个数字?
How would one need to modify one of these examples, to have at least a capital and a nubmer inside the password?
http://javascript.internet.com/passwords/password-generator.html
http://www.blazonry.com/javascript/password.php
或任何其他示例:)
推荐答案
我的头顶:
function generatePassword(len){
var pwd = [], cc = String.fromCharCode, R = Math.random, rnd, i;
pwd.push(cc(48+(0|R()*10))); // push a number
pwd.push(cc(65+(0|R()*26))); // push an upper case letter
for(i=2; i<len; i++){
rnd = 0|R()*62; // generate upper OR lower OR number
pwd.push(cc(48+rnd+(rnd>9?7:0)+(rnd>35?6:0)));
}
// shuffle letters in password
return pwd.sort(function(){ return R() - .5; }).join('');
}
这篇关于jquery 或 javascript 密码生成器,至少有一个大写和一个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文