1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Extended version of SpeakAblePassWord routine
// modified by Marcelo Castro
//
// Enviado por baraozemo
//
// Adaptado por Giovani Da Cruz
//
// syntax: GeneratePass(number_of_syllables,decimal_part)
function GeneratePass(syllables, numbers: Byte): string;
const
conso: array [0 .. 19] of Char = ('b', 'c', 'd', 'f', 'g', 'h',
'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w',
'x', 'y', 'z');
vocal: array [0 .. 4] of Char = ('a', 'e', 'i', 'o', 'u');
var
I: Integer;
si, sf: Longint;
n: string;
begin
Result := '';
Randomize;
if syllables > 0 then
begin
for I := 1 to syllables do
begin
Result := Result + conso[Random(19)];
Result := Result + vocal[Random(4)];
end;
end;
if numbers = 1 then
Result := Result + IntToStr(Random(9))
else if numbers >= 2 then
begin
if numbers > 9 then
numbers := 9;
si := StrToInt('1' + StringOfChar('0', numbers - 1));
sf := StrToInt(StringOfChar('9', numbers));
n := FloatToStr(si + Random(sf));
Result := Result + Copy(n, 0, numbers);
end;
end;
{ ———————————————–
utilization:
============
Escolha o número de letras e o número de dígitos:
ex: GeneratePass(3,2) => ‘pavoco53’
ex: GeneratePass(3,4) => ‘yegise7955’
ex: GeneratePass(5,0) => ‘yagotoxa’
ex: GeneratePass(0,9) => ‘568597284’ }
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GeneratePass(3,2));
ShowMessage(GeneratePass(3,4));
ShowMessage(GeneratePass(5,0));
ShowMessage(GeneratePass(0,9));
end; |