产生随机密码或字符串

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
function RandomPassword(PLen: Integer): string;
var
str: string;
begin
Randomize;
//string with all possible chars
str := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PLen)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//generate a password with 10 chars
label1.Caption := RandomPassword(10);
end;
 
// Another function from ReNoiZer /=RNZ=/; renoizer@mail.ru
function RandomWord(dictSize, lngStepSize, wordLen, minWordLen: Integer): string;
begin
Result := '';
if (wordLen < minWordLen) and (minWordLen > 0) then
wordLen := minWordLen
else if (wordLen < 1) and (minWordLen < 1) then wordLen := 1;
repeat
Result := Result + Chr(Random(dictSize) + lngStepSize);
until (Length(Result) = wordLen);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//generate a password with 10 chars
Caption := RandomWord(33, 54, Random(12), 2);
end;
 
 

Similar threads

I
回复
0
查看
652
import
I
I
回复
0
查看
582
import
I
I
回复
0
查看
574
import
I
I
回复
0
查看
488
import
I
I
回复
0
查看
692
import
I
后退
顶部