난수 문자열 만들기
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 and (minWordLen 0) then
wordLen := minWordLen
else if (wordLen and (minWordLen 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;
'Delphi Tip > 문자' 카테고리의 다른 글
델파이 UTF-8 (0) | 2023.11.15 |
---|---|
Case문으로 문자 비교하기 (0) | 2023.11.08 |
String 을 PAnsiChar 변환 (0) | 2021.10.14 |
문자 사이에서 숫자 추출하기 (0) | 2021.10.12 |
문자열에서 특정 단어가 몇번 들어갔는지 체크하는 함수 (0) | 2021.10.11 |
댓글