function RandomPassword(PasswordLength: Integer): string;
var
str: string;
begin
Randomize;
str := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PasswordLength)
end;
var
str: string;
begin
Randomize;
str := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PasswordLength)
end;
本文介绍了一个简单的随机密码生成器函数,该函数使用Delphi/Pascal语法编写。通过指定密码长度,函数可以从预定义的字符集中随机选取字符来生成密码。

374

被折叠的 条评论
为什么被折叠?



