I am developing a cross platform application for Windows, OSX and Linux and stubled upon an AES problem in LINUX. This code works well in both Windows and OSX but crashes on decryption in Linux. The key is 32 chars fixed in code. It is used for encrypting a DBServer password in the config file.
function TBaseConfig.encrypt(s: string): string;
var
aes: TAESEncryption;
begin
aes := TAESEncryption.Create;
aes.AType := atCBC;
aes.KeyLength := kl256;
aes.Unicode := noUni;
aes.Key := APPKEY;
aes.OutputFormat := base64;
aes.PaddingMode := TpaddingMode.PKCS7;
aes.IVMode := TIVMode.rand;
result := aes.encrypt(s);
aes.Free;
end;
function TBaseConfig.decrypt(s: string): string;
var
aes: TAESEncryption;
begin
aes := TAESEncryption.Create;
aes.AType := atCBC;
aes.KeyLength := kl256;
aes.Unicode :=noUni;
aes.Key := APPKEY;
aes.outputFormat := base64;
aes.PaddingMode := TpaddingMode.PKCS7;
aes.IVMode := TIVMode.rand;
result := aes.decrypt(s);
aes.Free;
end;
Thanks for any help and merry christmas!