1805/093
AS3-无聊的密码生成器
怎么说呢这个……的确是因为无聊,经常注册一些不想注册的网站,需要用到用户密码,但是又不想用自己常用的密码,觉得随便输又不太好,,SO,。弄了这么个Flash。
用法很简单,1)在"密码字符串允许值"中输入允许的密码值,设置了只能输入0-9,a-z;2)然后设置密码的长度,设置了6-16;3)点击"生成密码"生成密码,嘿嘿。
代码部分:
init();
var MINLENGTH:uint=6;
var MAXLENGTH:uint=16;
function init(){
iptStr.restrict="0-9a-z";
iptLength.restrict="0-9";
btnGenerate.addEventListener(MouseEvent.CLICK,generatePassword);
}
function generatePassword(_evt:MouseEvent){
var _strTemp:String="";
var _strPwdAllowed:String=iptStr.text;
var numLenth=int(iptLength.text);
if(checkLength(numLenth)){
for(var i:uint=0;i<numlenth ;i++){
_strTemp+=_strPwdAllowed.charAt(Math.random()*_strPwdAllowed.length);
}
showPwd(_strTemp);
}
}
function checkLength(_numLenth:int):Boolean{
if(_numLenth<MINLENGTH || _numLenth>MAXLENGTH){
showPwd("长度超过限制,应为 "+ MINLENGTH +" - "+ MAXLENGTH +"字符!");
return false;
}else{
return true;
}
}
function showPwd(_str:String){
rsPwd.text=_str;
}
July 14th, 2009 - 14:05
无意中逛到,你很强。
[Reply]
DFdou Reply:
2009-7-14 at 5:43 pm
@ibio, @.@
[Reply]
December 25th, 2009 - 11:57
[Reply]