Hello, the following function does not bring the correct expected result.
It seems the problem occurs when there are special characters like Ä included.
Could you please check and improve?
Thanks and Regards
procedure TDemoForm.AESBtnClick(Sender: TObject);
var
OutText, InText: string;
AES: TAESEncryption;
ExpectedText: string;
begin
AES := TAESEncryption.Create(nil);
try
ExpectedText := 'AEF123656%01j1gSüÄUh9rQQPXc9d)SKDJNHSG&%564ou8'; //This should be the result
MainMemo.Lines.Add('Soll:');
MainMemo.Lines.Add(ExpectedText);
AES.AType := atCBC;
AES.KeyLength := kl256;
AES.PaddingMode := PKCS7;
AES.Unicode := yesUni; // sehr wichtig bei Umlauten
AES.InputFormat := noFormat;
AES.OutputFormat := hexa;
AES.Key := '54%$4FB654(/C5FC02DFlkJ&%F4B9DA7';
OutText := AES.Encrypt(ExpectedText); //Encrypt and Decrypt have different results
InText := AES.Decrypt(OutText);
MainMemo.Lines.Add('Ist:');
MainMemo.Lines.Add(InText);
//InText is now the encrypted string from old Version 4
InText := AES.Decrypt('5398A41817C418359AD546B42D969D39A2536CAB1AD234D3A72E39109A9D1A8E179170C475FD7B175429EFFEF5ACACD197284B11E77059EB9ADBB0F053B2CDE7322057126376364B243F7625275A663C');
MainMemo.Lines.Add(InText);
Hello Bernard,
I tryed your verstion but still the Ä ist not shown in the output:
Soll:
AEF123656%01j1gSüÄUh9rQQPXc9d)SKDJNHSG&%564ou8
Ist:
AEF123656%01j1gSüh9rQQPXc9d)SKDJNHSG&%564ou8
AEF123656%01j1gSüh9rQQPXc9d)SKDJNHSG&%564ou8
Here is my function:
procedure TDemoForm.AESBtnClick(Sender: TObject);
var
OutText, InText: string;
AES: TAESEncryption;
ExpectedText: string;
Conv: TConvert;
begin
AES := TAESEncryption.Create(nil);
try
ExpectedText := 'AEF123656%01j1gSüÄUh9rQQPXc9d)SKDJNHSG&%564ou8'; //This should be the result
MainMemo.Lines.Add('Soll:');
MainMemo.Lines.Add(ExpectedText);
Conv := TConvert.Create(hexa);
AES.AType := atCBC;
AES.KeyLength := kl256;
AES.PaddingMode := PKCS7; //AES.Unicode := yesUni; // sehr wichtig bei Umlauten
AES.InputFormat := raw;
AES.OutputFormat := raw;
AES.Key := '54%$4FB654(/C5FC02DFlkJ&%F4B9DA7';
OutText := AES.Encrypt(ExpectedText); //Encrypt and Decrypt have different results
InText := AES.Decrypt(OutText);
MainMemo.Lines.Add('Ist:');
MainMemo.Lines.Add(InText);
//InText is now the encrypted string from old Version 4
InText := Conv.FormatToChar('5398A41817C418359AD546B42D969D39A2536CAB1AD234D3A72E39109A9D1A8E179170C475FD7B175429EFFEF5ACACD197284B11E77059EB9ADBB0F053B2CDE7322057126376364B243F7625275A663C');
ExpectedText := AES.Decrypt(InText);
//InText := AES.Decrypt('5398A41817C418359AD546B42D969D39A2536CAB1AD234D3A72E39109A9D1A8E179170C475FD7B175429EFFEF5ACACD197284B11E77059EB9ADBB0F053B2CDE7322057126376364B243F7625275A663C');
MainMemo.Lines.Add(ExpectedText);