Delphi 随机字符3

2022-12-29 09:13:12 作者:admin

本文整理自网络,侵删。

 
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 tms web core直接从html&css设计的页面布局

Delphi 10.2 新特性之―tfdbatchmovejsonwriter

Delphi xe 版本 示例原码下载

Delphi 字串转16进制

Delphi android gps服务

Delphi 两个exe之间共享数据

Delphi 释放bitmap

Delphi xe datasnap服务器获取客户端ip地址

Delphi idhttp使用代理ip

Delphi 获取百度ai 获取token

更多相关阅读请进入《Delphi》频道 >>



在线咨询 拨打电话