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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
(*----------------------------------------------------------------------------*)
(* FlashPascal 2 *)
(* Générateur de mot de passe *)
(* FlashCL : http://flashpascal.execute.re/FlashCL.php *)
(*----------------------------------------------------------------------------*)
program Generateur;
{$FRAME_WIDTH 540}
{$FRAME_HEIGHT 400}
uses
Flash8, Classes, Controls, StdCtrls;
const
L = 'abcdefghijklmnopqrstuvwxyz';
C = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
D = '0123456789';
var
S: string;
function RandomWord(
aLength: integer;
aDigits: boolean;
aCapitals: boolean;
aLowerChars: boolean;
aSpecialChars: boolean): string;
var
a: array[1..4]of integer;
i: integer;
begin
i := 0;
if aDigits then
begin
Inc(i);
a[i] := 1;
end;
if aCapitals then
begin
Inc(i);
a[i] := 2;
end;
if aLowerChars then
begin
Inc(i);
a[i] := 3;
end;
if aSpecialChars then
begin
Inc(i);
a[i] := 4;
end;
result := '';
if i > 0 then
while Length(result) < aLength do
case a[Trunc(i * Random + 1)] of
1: result := result + D[Trunc(10 * Random + 1)];
2: result := result + C[Trunc(26 * Random + 1)];
3: result := result + L[Trunc(26 * Random + 1)];
4: result := result + S[Trunc(Length(S) * Random + 1)];
end;
end;
var
bb: array[1..4] of TCheckBox;
ff: array[1..6] of TextField;
type
TCustomButton = class(MovieClip)
caption: TextField;
procedure DrawButton(backColor, topColor, bottomColor, width, height: integer);
end;
TButton = class(TCustomButton)
constructor Create(left, top, width, height: integer; aCaption: string);
procedure doClick;
procedure onRelease; override;
end;
{ TCustomButton }
procedure TCustomButton.DrawButton(
backColor,
topColor,
bottomColor,
width,
height: integer
);
begin
BeginFill(backColor);
LineStyle(1, topColor);
MoveTo(0, height);
LineTo(0, 0);
LineTo(width, 0);
LineStyle(1, bottomColor);
LineTo(width, height);
LineTo(0, height);
EndFill;
end;
{ TButton }
constructor TButton.Create(left, top, width, height: integer; aCaption: string);
var
f: textFormat;
begin
inherited Create(nil, '', GetNextHighestDepth());
_x := left;
_y := top;
DrawButton($D0D0D0, $E0E0E0, $808080, width, height);
caption := TextField.Create(
self,
'',
GetNextHighestDepth(),
0,
5,
width,
height
);
caption.text := aCaption;
f := TextFormat.Create('Arial', 12);
f.align := 'center';
caption.SetTextFormat(0, Length(caption.text), f);
onPress := doClick;
end;
procedure TButton.doClick;
var
i: integer;
begin
DrawButton(
$C0C0C0,
$808080,
$E0E0E0,
integer(caption._width),
integer(caption._height)
);
ff[5].text := '';
S := ff[6].text;
if bb[1].checked
or bb[2].checked
or bb[3].checked
or bb[4].checked then
for i := 1 to integer(StrToInt(ff[4].text)) do
ff[5].text := ff[5].text + RandomWord(
integer(StrToInt(ff[2].text)),
bb[1].checked,
bb[2].checked,
bb[3].checked,
bb[4].checked
) + #13;
end;
procedure TButton.onRelease;
begin
DrawButton(
$D0D0D0,
$E0E0E0,
$808080,
integer(caption._width),
integer(caption._height)
);
end;
var
i: integer;
b: TButton;
f: TextFormat;
begin
for i := Low(bb) to High(bb) do
begin
bb[i] := TCheckBox.Create(_root);
with bb[i] do
SetBounds(10, 30 * i - 20, 530, 21);
end;
bb[1].Caption := 'Inclure des chiffres';
bb[2].Caption := 'Inclure des lettres majuscules';
bb[3].Caption := 'Inclure des lettres minuscules';
bb[4].Caption := 'Inclure des caract'"è"'res sp'"é"'ciaux :';
bb[1].checked := TRUE;
bb[3].checked := TRUE;
f := textFormat.Create('Arial', 12);
ff[1] := TextField.Create(_root, '', 4, 10, 130, 480, 21);
ff[1].SetNewTextFormat(f);
ff[1].Text := 'Nombre de caract'"è"'res souhait'"é"'s :';
ff[3] := TextField.Create(_root, '', 5, 10, 160, 480, 21);
ff[3].SetNewTextFormat(f);
ff[3].Text := 'Nombre de mots de passe '"à"' g'"é"'n'"é"'rer :';
ff[2] := TextField.Create(_root, '', 6, 500, 130, 30, 21);
ff[2].SetNewTextFormat(f);
ff[2].type := 'input';
ff[2].border := TRUE;
ff[2].text := '12';
ff[4] := TextField.Create(_root, '', 7, 500, 160, 30, 21);
ff[4].SetNewTextFormat(f);
ff[4].type := 'input';
ff[4].border := TRUE;
ff[4].text := '10';
ff[6] := TextField.Create(_root, '', 9, 330, 100, 200, 21);
ff[6].SetNewTextFormat(f);
ff[6].type := 'input';
ff[6].border := TRUE;
ff[6].text := '!#$%&()*+,-./:;<=>?@[\]^_{|}~';
ff[5] := TextField.Create(_root, '', 8, 10, 190, 520, 160);
ff[5].SetNewTextFormat(f);
ff[5].border := TRUE;
b := TButton.Create(195, 360, 150, 30, 'G'"é"'n'"é"'rer');
end. |
Partager