Skip to content

Commit d7c8db9

Browse files
BtnDecryption will be enabled also when copy chiffre and key
1 parent 57e4a5b commit d7c8db9

File tree

4 files changed

+126
-19
lines changed

4 files changed

+126
-19
lines changed

AsymmetricEncryptionFrm.dfm

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
2525
object ShapeResult: TShape
2626
Left = 24
2727
Top = 416
28-
Width = 565
28+
Width = 559
2929
Height = 65
3030
Anchors = [akLeft, akTop, akRight]
3131
Shape = stRoundRect
@@ -34,7 +34,7 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
3434
object LabelResult: TLabel
3535
Left = 55
3636
Top = 440
37-
Width = 510
37+
Width = 504
3838
Height = 20
3939
Alignment = taCenter
4040
Anchors = [akLeft, akTop, akRight]
@@ -62,26 +62,49 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
6262
Caption = 'Private Key'
6363
end
6464
object LabelKeySize: TLabel
65-
Left = 437
65+
Left = 431
6666
Top = 32
6767
Width = 71
6868
Height = 15
6969
Anchors = [akTop, akRight]
7070
Caption = 'Key size [bits]'
71+
ExplicitLeft = 437
7172
end
7273
object lblChiffreLen: TLabel
73-
Left = 448
74+
Left = 442
7475
Top = 293
7576
Width = 129
7677
Height = 15
7778
Alignment = taRightJustify
7879
Anchors = [akTop, akRight]
7980
AutoSize = False
81+
ExplicitLeft = 448
82+
end
83+
object Label1: TLabel
84+
Left = 24
85+
Top = 167
86+
Width = 51
87+
Height = 15
88+
Caption = 'Clear Text'
89+
end
90+
object Label2: TLabel
91+
Left = 24
92+
Top = 247
93+
Width = 36
94+
Height = 15
95+
Caption = 'Chiffre'
96+
end
97+
object Label3: TLabel
98+
Left = 24
99+
Top = 347
100+
Width = 103
101+
Height = 15
102+
Caption = 'Resulting Clear Text'
80103
end
81104
object EditClear: TEdit
82105
Left = 24
83-
Top = 168
84-
Width = 559
106+
Top = 187
107+
Width = 553
85108
Height = 23
86109
Anchors = [akLeft, akTop, akRight]
87110
TabOrder = 0
@@ -99,11 +122,12 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
99122
end
100123
object EditEncrypted: TEdit
101124
Left = 24
102-
Top = 264
103-
Width = 559
125+
Top = 268
126+
Width = 553
104127
Height = 23
105128
Anchors = [akLeft, akTop, akRight]
106129
TabOrder = 2
130+
OnChange = EditEncryptedChange
107131
end
108132
object btnDecrypt: TButton
109133
Left = 24
@@ -118,7 +142,7 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
118142
object cboAlgo: TComboBox
119143
Left = 112
120144
Top = 29
121-
Width = 289
145+
Width = 283
122146
Height = 23
123147
Style = csDropDownList
124148
Anchors = [akLeft, akTop, akRight]
@@ -132,16 +156,18 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
132156
'RsaOaepSha256'
133157
'RsaOaepSha384'
134158
'RsaOaepSha512')
159+
ExplicitWidth = 277
135160
end
136161
object EditResult: TEdit
137162
Left = 24
138163
Top = 368
139-
Width = 565
164+
Width = 559
140165
Height = 23
141166
Anchors = [akLeft, akTop, akRight]
142167
ReadOnly = True
143168
TabOrder = 5
144169
TextHint = 'resulting clear text'
170+
ExplicitWidth = 553
145171
end
146172
object btnCreateKeys: TButton
147173
Left = 24
@@ -155,23 +181,25 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
155181
object EditPublicKey: TEdit
156182
Left = 120
157183
Top = 112
158-
Width = 463
184+
Width = 457
159185
Height = 23
160186
Anchors = [akLeft, akTop, akRight]
161187
TabOrder = 7
162188
OnChange = EditKeyChange
189+
ExplicitWidth = 451
163190
end
164191
object EditPrivateKey: TEdit
165192
Left = 120
166193
Top = 139
167-
Width = 463
194+
Width = 457
168195
Height = 23
169196
Anchors = [akLeft, akTop, akRight]
170197
TabOrder = 8
171198
OnChange = EditKeyChange
199+
ExplicitWidth = 451
172200
end
173201
object btnSaveKeys: TButton
174-
Left = 353
202+
Left = 347
175203
Top = 72
176204
Width = 68
177205
Height = 25
@@ -180,9 +208,10 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
180208
Enabled = False
181209
TabOrder = 9
182210
OnClick = btnSaveKeysClick
211+
ExplicitLeft = 341
183212
end
184213
object btnSaveEncrypt: TButton
185-
Left = 427
214+
Left = 421
186215
Top = 216
187216
Width = 75
188217
Height = 25
@@ -191,9 +220,10 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
191220
Enabled = False
192221
TabOrder = 10
193222
OnClick = btnSaveEncryptClick
223+
ExplicitLeft = 415
194224
end
195225
object btnLoadEncrypt: TButton
196-
Left = 508
226+
Left = 502
197227
Top = 216
198228
Width = 75
199229
Height = 25
@@ -202,29 +232,32 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
202232
Enabled = False
203233
TabOrder = 11
204234
OnClick = btnLoadEncryptClick
235+
ExplicitLeft = 496
205236
end
206237
object btnLoadKeys: TButton
207-
Left = 427
238+
Left = 421
208239
Top = 72
209240
Width = 75
210241
Height = 25
211242
Anchors = [akTop, akRight]
212243
Caption = 'Load Keys'
213244
TabOrder = 12
214245
OnClick = btnLoadKeysClick
246+
ExplicitLeft = 415
215247
end
216248
object btnLoadPubKey: TButton
217-
Left = 508
249+
Left = 502
218250
Top = 72
219251
Width = 75
220252
Height = 25
221253
Anchors = [akTop, akRight]
222254
Caption = 'Load Public'
223255
TabOrder = 13
224256
OnClick = btnLoadPubKeyClick
257+
ExplicitLeft = 496
225258
end
226259
object cboKeySize: TComboBox
227-
Left = 514
260+
Left = 508
228261
Top = 29
229262
Width = 69
230263
Height = 23
@@ -237,5 +270,6 @@ object frmAsymmetricEncryption: TfrmAsymmetricEncryption
237270
'2048'
238271
'3072'
239272
'4096')
273+
ExplicitLeft = 502
240274
end
241275
end

AsymmetricEncryptionFrm.pas

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ TfrmAsymmetricEncryption = class(TForm)
5656
cboKeySize: TComboBox;
5757
LabelKeySize: TLabel;
5858
lblChiffreLen: TLabel;
59+
Label1: TLabel;
60+
Label2: TLabel;
61+
Label3: TLabel;
5962
procedure btnEncryptClick(Sender: TObject);
6063
procedure btnDecryptClick(Sender: TObject);
6164
procedure btnCreateKeysClick(Sender: TObject);
@@ -67,11 +70,13 @@ TfrmAsymmetricEncryption = class(TForm)
6770
procedure cboAlgoChange(Sender: TObject);
6871
procedure FormCreate(Sender: TObject);
6972
procedure EditKeyChange(Sender: TObject);
73+
procedure EditEncryptedChange(Sender: TObject);
7074
private
7175
fDataFolder: string;
7276
function SelectedAlgo: Core_IAsymmetricKeyAlgorithmProvider;
7377
function SelectedKeyLength: integer;
7478
procedure InitWithNewKeys;
79+
procedure CheckButtons;
7580
procedure ShowError(const Msg: string);
7681
procedure ShowWarning(const Msg: string);
7782
procedure ShowResult(const Msg: string);
@@ -152,9 +157,22 @@ procedure TfrmAsymmetricEncryption.ClearResult;
152157
ShapeResult.Brush.Color := clBtnFace;
153158
LabelResult.Caption := '';
154159
end;
160+
161+
procedure TfrmAsymmetricEncryption.EditEncryptedChange(Sender: TObject);
162+
begin
163+
CheckButtons;
164+
end;
165+
155166
procedure TfrmAsymmetricEncryption.EditKeyChange(Sender: TObject);
156167
begin
157168
TEdit(Sender).Color := clWindow;
169+
CheckButtons;
170+
end;
171+
172+
procedure TfrmAsymmetricEncryption.CheckButtons;
173+
begin
174+
btnDecrypt.Enabled := (length(EditPrivateKey.Text) > 0) and
175+
(length(EditEncrypted.Text) > 0);
158176
end;
159177

160178
{$ENDREGION}

SymmetricEncryptionFrm.dfm

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
7171
Height = 15
7272
Caption = 'IV'
7373
end
74+
object Label1: TLabel
75+
Left = 24
76+
Top = 139
77+
Width = 51
78+
Height = 15
79+
Caption = 'Clear Text'
80+
end
81+
object Label2: TLabel
82+
Left = 24
83+
Top = 239
84+
Width = 36
85+
Height = 15
86+
Caption = 'Chiffre'
87+
end
88+
object Label3: TLabel
89+
Left = 24
90+
Top = 319
91+
Width = 103
92+
Height = 15
93+
Caption = 'Resulting Clear Text'
94+
end
7495
object cboAlgo: TComboBox
7596
Left = 112
7697
Top = 29
@@ -87,6 +108,7 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
87108
'AesCbcPkcs7'
88109
'AesEcb'
89110
'AesEcbPkcs7')
111+
ExplicitWidth = 341
90112
end
91113
object btnCreateKey: TButton
92114
Left = 24
@@ -105,6 +127,7 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
105127
Anchors = [akLeft, akTop, akRight]
106128
TabOrder = 2
107129
OnChange = EditKeyChange
130+
ExplicitWidth = 469
108131
end
109132
object EditClear: TEdit
110133
Left = 24
@@ -114,6 +137,7 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
114137
Anchors = [akLeft, akTop, akRight]
115138
TabOrder = 3
116139
TextHint = 'Clear text'
140+
ExplicitWidth = 559
117141
end
118142
object btnEncrypt: TButton
119143
Left = 24
@@ -132,10 +156,12 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
132156
Height = 23
133157
Anchors = [akLeft, akTop, akRight]
134158
TabOrder = 5
159+
OnChange = EditEncryptedChange
160+
ExplicitWidth = 559
135161
end
136162
object btnDecrypt: TButton
137163
Left = 24
138-
Top = 301
164+
Top = 285
139165
Width = 75
140166
Height = 25
141167
Caption = 'Decrypt'
@@ -152,6 +178,7 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
152178
ReadOnly = True
153179
TabOrder = 7
154180
TextHint = 'resulting clear text'
181+
ExplicitWidth = 565
155182
end
156183
object btnSaveEncrypt: TButton
157184
Left = 445
@@ -183,6 +210,7 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
183210
Enabled = False
184211
TabOrder = 10
185212
OnClick = btnSaveKeyClick
213+
ExplicitLeft = 434
186214
end
187215
object btnLoadKey: TButton
188216
Left = 514
@@ -218,12 +246,15 @@ object FrmSymmetricEncryption: TFrmSymmetricEncryption
218246
'128'
219247
'192'
220248
'256')
249+
ExplicitLeft = 514
250+
ExplicitTop = 28
221251
end
222252
object EditIV: TEdit
223253
Left = 136
224254
Top = 209
225255
Width = 297
226256
Height = 23
227257
TabOrder = 14
258+
OnChange = EditIVChange
228259
end
229260
end

0 commit comments

Comments
 (0)