MHumm / DelphiEncryptionCompendium

Cryptographic library for Embarcadero Delphi and potentially for FPC as well
Apache License 2.0
255 stars 66 forks source link

Cipher_FMX program logic wrong ? #27

Closed bdwilton closed 3 years ago

bdwilton commented 3 years ago

Hello, I was just testing the Cipher_FMX program.

I set the Input format to TFormat_Copy and output to TFormat_Hex

Setup the rest and put 'Hello' into the plain text and press Encrypt. Then press Decrypt and its not correct.

Could be my logic or thinking of course.

In the procedure TFormMain.ButtonDecryptClick(Sender: TObject);

I swapped the following which gets it working.

OutputBuffer := (Cipher as TDECFormattedCipher).DecodeBytes(OutputFormatting.Decode(InputBuffer));

EditPlainText.Text := string(DECUtil.BytesToRawString(InputFormatting.Encode(OutputBuffer)));

// OutputBuffer := (Cipher as TDECFormattedCipher).DecodeBytes(InputFormatting.Decode(InputBuffer)); // // EditPlainText.Text := string(DECUtil.BytesToRawString(OutputFormatting.Encode(OutputBuffer)));

MHumm commented 3 years ago

Fixed in developer branch, thanks for providing this fix!