本文整理自网络,侵删。
function GeneratePassword(PasswordLength: Integer):string;var SourceString: String; ExcludeString: String; RandomCharacter: String; RandomPassword: String;
NumPassword: Integer;
begin Randomize;
SourceString := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:!?''"()@'; ExcludeString := '0O1lI|';
if Length(SourceString) = 0 then exit;
for NumPassword := 1 to 20 do begin RandomPassword := ''; repeat
// RandomCharacter := SourceString[Random(Length(SourceString)) + 1 ]; RandomCharacter := SourceString.Substring(Random(Length(SourceString)),1);
// if Pos( RandomCharacter, ExcludeString) = 0 then if ExcludeString.IndexOf(RandomCharacter) = -1 then RandomPassword := RandomPassword + RandomCharacter; until (Length(RandomPassword) = PasswordLength);
result:= RandomPassword end;
end;
相关阅读 >>
Delphi getforegroundwindow 与 getactivewindow 的区别
Delphi 在rxrichedit中插入图片的完美解决方法
winapi 字符及字符串函数(5): ischaralpha - 是否是个字母
Delphi下idhttp配合cookiemanager获取cookie
Delphi 2009 indy10 idhttp get 中文出现乱码的问题
Delphi+access错误"不正常地定义参数对象。提供了不一致或不完整的信息。"
更多相关阅读请进入《Delphi》频道 >>