-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.pas
132 lines (91 loc) · 3.34 KB
/
MainForm.pas
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
{ d8 dP 8b
d8' 88 `8b
d8' 88d888b. dP dP 88 .dP .d8888b. 88d888b. .d8888b. .d8888b. .d8888b. .d8888b. `8b
Y8. 88' `88 88 88 88888" 88ooood8 88' `88 88' `88 88' `88 88' `88 88' `88 .8P
Y8. 88 88. .88 88 `8b. 88. ... 88 88. .88 88. .88 88. .88 88. .88 .8P
Y8 dP `8888P88 dP `YP `88888P' dP `8888P88 `88888P' `8888P88 `88888P' 8P
.88 .88 .88
d8888P d8888P d8888P }
unit MainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Hash, System.Math, Helpers;
type
TdWordForm = class(TForm)
signatureListBox: TListBox;
genBtn: TButton;
signatureNum: TEdit;
signaturelbl: TStaticText;
procedure genBtnClick(Sender: TObject);
procedure signatureNumChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
dWordForm: TdWordForm;
setNumPass: Integer = -1;
flagValid: bool = true;
implementation
{$R *.dfm}
procedure TdWordForm.genBtnClick(Sender: TObject);
{ This will handle the generation of the signatures based on number provided
by user. }
var
i: Integer;
hashes: TextFile;
saveTime: TDateTime;
begin
try
// Valid flag is set to true here in case it was false previously.
setNumPass := StrToInt(signatureNum.Text);
flagValid := true;
except
// Tell the system the input is not valid!
flagValid := false;
Application.MessageBox('Not a valid number.', 'Error', MB_OK Or MB_ICONERROR);
end;
if (setNumPass > 0) And (flagValid) then
begin
// Clear any previous entries
signatureListBox.Clear;
for i := 1 to setNumPass do
begin
signatureListBox.Items.Add(genHash);
end;
// Success message + reset and cleanup of controls.
signatureNum.Text := '';
setNumPass := -1;
Application.MessageBox('Signatures generated.', 'Done', MB_OK Or MB_ICONINFORMATION);
{ Handle saving hashes to file. }
if Application.MessageBox('Save to file?', 'Save',
MB_YESNO Or MB_ICONQUESTION) = IDYES then
begin
saveTime := Now;
AssignFile(hashes, 'hashes.txt');
Rewrite(hashes);
writeln(hashes, '# Generated by dWord - https://github.com/rykergogo/dWord');
writeln(hashes, '# Date: ' + DateTimeToStr(saveTime));
writeln(hashes, '# Count: ' + IntToStr(signatureListBox.Items.Count));
writeln(hashes, '');
writeln(hashes, '');
for i := 0 to signatureListBox.Items.Count-1 do
begin
writeln(hashes, signatureListBox.Items[i]);
end;
Closefile(hashes);
end;
end
// This will trigger when user inputs 0 or negative num.
else if ((setNumPass = 0) Or (setNumPass < 0)) And (flagValid) then
begin
Application.MessageBox('Can''t generate negative/no signatures.', 'Error', MB_OK Or MB_ICONERROR);
end;
end;
procedure TdWordForm.signatureNumChange(Sender: TObject);
begin
genBtn.Enabled := true;
end;
end.