41 lines
1 KiB
Text
41 lines
1 KiB
Text
string 0;
|
|
|
|
func In(C, Str);
|
|
char C, Str;
|
|
[while Str(0) do
|
|
if C = Str(0) then return true else Str:= Str+1;
|
|
return false;
|
|
];
|
|
|
|
func New_password(Length, Readable);
|
|
int Length, Readable, I, C;
|
|
char Password_chars(100), Punctuation, Visually_similar;
|
|
[if Length < 4 then
|
|
[Text(0, "Password length = "); IntOut(0, Length);
|
|
Text(0, " is too short, minimum length = 4.");
|
|
return "";
|
|
];
|
|
Punctuation:= "!^"#$%&\'()*+,-./:;<=>?@[]^^_{|}~";
|
|
Visually_similar:= "Il1O05S2Z";
|
|
for I:= 0 to Length-1 do
|
|
[case Ran(4) of
|
|
0: C:= Ran(26) + ^a;
|
|
1: C:= Ran(26) + ^A;
|
|
2: C:= Ran(10) + ^0;
|
|
3: C:= Punctuation(Ran(31))
|
|
other [];
|
|
Password_chars(I):= C;
|
|
if Readable and In(C, Visually_similar) then I:= I-1;
|
|
];
|
|
Password_chars(I):= 0;
|
|
return Password_chars;
|
|
];
|
|
|
|
proc Password_generator(Length, Qty, Readable);
|
|
int Length, Qty, Readable, I;
|
|
for I:= 0 to Qty-1 do
|
|
[Text(0, New_password(Length, Readable)); CrLf(0)];
|
|
|
|
[Password_generator(14, 4, true);
|
|
Password_generator( 8, 4, false);
|
|
]
|