Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
Does anybody have a more "elegant" way of doing this?
#DefineFunction gen_pswd(pw_len); pw = '' s1 = 'BCDFGHJKLMNPQRSTVWXZ'; s2 = 'AEIOUY'; For j=1 To pw_len If j mod 2 ;if even seed = StrLen(s2) value = StrSub(s2,Random(seed)+1,1) pw=StrCat(pw,value) Else seed = StrLen(s1) value = StrSub(s1,Random(seed)+1,1) pw=StrCat(pw,value) endif; Next Return pw #EndFunction pw_length = 14 password = gen_pswd(pw_length); Message("Password",password) Exit
:askagain pw_len=AskLine("Password Generator", "Enter the password length", '6') If IsInt(pw_Len)==@FALSE Then Goto askagain upflg=AskYesNo("Password Generator", "Should Upper Case characters be a possibility?") lwflg=AskYesNo("Password Generator", "Should Lower Case characters be a possibility?") syflg=AskYesNo("Password Generator", "Should Symbol characters be a possibility?") nmflg=AskYesNo("Password Generator", "Should Numeric characters be a possibility?") :top pw='' upset=@FALSE lwset=@FALSE syset=@FALSE nmset=@FALSE While StrLen(pw)<pw_len val=Random(126) If val<=32 Then Continue If val<=47 If syflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) syset=@TRUE EndIf Continue EndIf If val<=57 If nmflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) nmset=@TRUE EndIf Continue EndIf If val<=64 If syflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) syset=@TRUE EndIf Continue EndIf If val<=90 If upflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) upset=@TRUE EndIf Continue EndIf If val<=96 If syflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) syset=@TRUE EndIf Continue EndIf If val<=122 If lwflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) lwset=@TRUE EndIf Continue EndIf If val<=126 If syflg==@TRUE chr=Num2Char(val) pw=StrCat(pw,chr) syset=@TRUE EndIf Continue EndIf EndWhile If upset<>upflg || lwset<>lwflg || syset<>syflg || nmset<>nmflg Then Goto top AskLine("Password Results", 'Click OK to generate a new password.', pw) Goto top Exit
Article ID: W15337
File Created: 2011:05:06:07:47:34
Last Updated: 2011:05:06:07:47:34