Today I have updated TMS Cryptography Pack from 4.3.3.0 to 5.1.0.1.
My AES encryption procedure (which was working ok for some years) now generates an exception, when I call aes.Encrypt(s) an encryption fails.
function EncodeAES2String (const s, Key:string) : string;
var
aes : TAESEncryption;
i : Integer;
iv : string;
begin
Result := '';
aes:= TAESEncryption.Create;
try
aes.AType := atCBC;
aes.KeyLength := kl256;
aes.Unicode := yesUni;
if Key = '' then
aes.Key := BriSec32String
else
aes.Key := Key;
aes.OutputFormat := base64;
aes.PaddingMode := TpaddingMode.PKCS7;
iv := '';
for i := 1 to 16 do
iv := iv + Chr(0);
aes.IV := iv;
aes.IVMode := TIVMode.userdefined;
Result := aes.Encrypt(s);
finally
aes.Free;
end;
end;
Thank you for quick check!
When I run the program and click Encrypt, I receive the error, when I call Decrypt command:
error : in AES, the cipher text cannot be decrypted because the padding is not correct!
The issue with DCUs is quite frequent. I recommand you uninstall libraries and clean up all DCUs when installing a new version of ANY library, not only TMS CP.