I get TSimpleCodec.Begin_EncryptMemory - Wrong mode exception wile executing the following code. Is it something wrong?
FLibrary := TCryptographicLibrary.Create(Self);
FCodec := TCodec.Create(Self);
FCodec.CryptoLibrary := FLibrary;
FCodec.BlockCipherId := 'native.AES-256';
FCodec.ChainModeId := 'native.ECB';
FCodec.Password := 'password';
plain := 'The plain text';
FCodec.EncryptString(plain, astr);
FCodec.DecryptString(dec, astr);
When initialising the codec by run-time code, you need to set the StreamCipherId. Insert the following line just before setting the BlockCipherId.
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.
The demo program for Delphi 2010, gives an example in methods TmfmLockbox3_Demo.FormCreate() and TmfmLockbox3_Demo.actCustomBlockEncryptExecute() .
Also read the on-line help about it.
As a general hint, if you just look at the demo program and/or read the on-line help, you will rarely need to come to StackOverflow. If there are any short-comings in the documentation, please post some constructive actionable suggestions on the LockBox forums to improve the documentation (demos + on-line help).