Hi TMS support team. Can you please look at the code below? This used to work on Delphi 12.x with Crypt v4. Now using Delphi 13, i seem to have to use crypt v5 but it breaks the below functionality when decrypting the encrypted strings. What is the solution to get Decrypt working again?
function Encrypt(const AText: string; const APassword: string): string;
var
aes: TAESEncryption;
myPass : string;
begin
result := '';
MyPass := APassword;
MyPass := MyPass + StringOfChar (' ', 32 - Length(MyPass) ); { fill passphrase to a required length of 32 chars }
aes:= TAESEncryption.Create;
try
aes.AType := atCTR;
aes.keyLength := kl256;
aes.outputFormat := base64url;
aes.Key := myPass;
aes.PaddingMode := TpaddingMode.PKCS7;
aes.IVMode := TIVMode.rand;
aes.Unicode := yesUni;
result := aes.Encrypt(AText);
finally
aes.Free;
end;
end;
function Decrypt(const AText: string; const APassword: string): string;
var
aes: TAESEncryption;
myPass : string;
begin
result := '';
MyPass := APassword;
MyPass := MyPass + StringOfChar (' ', 32 - Length(MyPass) ); { fill passphrase to a required length of 32 chars }
try
aes:= TAESEncryption.Create;
try
aes.AType := atCTR;
aes.keyLength := kl256;
aes.outputFormat := base64url;
aes.Key := myPass;
aes.PaddingMode := TpaddingMode.PKCS7;
aes.IVMode := TIVMode.rand;
aes.Unicode := yesUni;
result := aes.Decrypt(AText);
finally
aes.Free;
end;
except
//
end;
end;