0

I am using Delphi XE6 and LockBox 3.4.3 to run the code actEncryptStringExecute. This code was posted as an answer to the question 'How to use AES-256 encryption in lockbox 3 using delphi'. The error I get is TSimpleCodec.Begin_EncryptMemory - Wrong mode.

There is another question 'TSimpleCodec.Begin_EncryptMemory - Wrong mode' where the answer is "You don't need to do this if you are setting up the codec with design-time values. It's much easier to do at design-time. Just set the published properties as required".

TCodec properties are :-
AdvancedOptions2 = []
AsymetricKeySizeInBits = 1024
ChainMode = ECB (with block padding)
Cipher = Base64
CryptoLibrary = CryptographicLibrary1
Encoding = (TEncoding)

TCryptographicLibrary properties are :-
CustomCipher = (TCustomStreamCipher)
Name = CryptographicLibrary1
ParentLibrary = 

The code is :-

var
base64CipherText          : String;
PlainTextStr              : String;
ReconstructedPlainTextStr : String;


procedure TForm1.btnEncryptClick(Sender: TObject);
begin
PlainTextStr := edtPlainText.Text;
Codec1.EncryptString(PlainTextStr, base64CipherText, TEncoding.Unicode);
lblEncrypted.Caption := base64CipherText;

Codec1.DecryptString(ReconstructedPlainTextStr, base64CipherText, TEncoding.Unicode);
lblReconstructed.Caption := base64CipherText;
end;

What do I need change at design time to get this most simple example to work?

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • You reference a procedure actEncryptStringExecute(), but you provide no listing for it (unless it is the same as btnEncryptClick()). Please clarify. You reference another question, but don't provide a link to it. Could you link to it please? – Sean B. Durkin Jul 10 '14 at 04:42
  • This is the link, I hope [link] (http://stackoverflow.com/questions/9449613/how-to-use-aes-256-encryption-in-lockbox-3-using-delphi/9453558#9453558) – Peter G Evans Jul 10 '14 at 04:51
  • It looks like you have not set the password. – Sean B. Durkin Jul 10 '14 at 05:17
  • I think the tip version LB3 (via SVN) is broken in a major way. I fix it. But I don't have authority to commit changes, so I will probably fork the project, and commit the fixes to the fork. – Sean B. Durkin Jul 10 '14 at 05:21
  • Interesting that you mention a Password. Neither of the components that I list the properties for have a property Password that I can see at design time. I appreciate that you have a fix. Would you be able to post here when the fix is available? – Peter G Evans Jul 10 '14 at 05:44
  • The password property is not published, but set at run-time. This is a deliberate design decision. If password was published and set at design time, people could see your password just by reading the DFM file. So 'password' is an exception to the rule - it must be run-time only. I'll probably post the fix on Monday. I hope that is early enough for you. – Sean B. Durkin Jul 10 '14 at 07:53
  • That would be fantastic. – Peter G Evans Jul 10 '14 at 12:05
  • I suggest that you don't need to put components on a form. It's cleaner to do this in code. – David Heffernan Jul 11 '14 at 06:20
  • It's done: https://code.google.com/p/tplockbox/ – Sean B. Durkin Jul 11 '14 at 10:56
  • Beautiful - I can now call the EncryptString routine in your new release - with the results I expected. Thank you. – Peter G Evans Jul 15 '14 at 02:01

0 Answers0