function btnGenerateClick(Sender: TObject): string;
{max length of generated password}
const
intMAX_PW_LEN = 10;
var
i: Byte;
s: string;
begin
{if you want to use the 'A..Z' characters}
if cbAZ.Checked then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';
{if you want to use the 'a..z' characters}
if cbAZSmall.Checked then
s := s + 'abcdefghijklmnopqrstuvwxyz';
{if you want to use the '0..9' characters}
if cb09.Checked then
s := s + '0123456789';
if s = '' then exit;
Result := '';
for i := 0 to intMAX_PW_LEN-1 do
Result := Result + s[Random(Length(s)-1)+1];
end;
本文介绍了一个简单的随机密码生成器的实现方法,通过选择不同的字符集(大写字母、小写字母、数字),可以生成指定长度的随机密码。该生成器使用了Delphi语言编写,并通过几个复选框来控制是否包含特定类型的字符。
2307

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



