Using code below with Delphi 13.1 - 64bit application - TMS Crypto 5.1.1.9
procedure TLicense.DoCreateEncryption;
begin
FEncryption := TAESEncryption.Create(nil);
FEncryption.AType := TAESType.atCBC;
FEncryption.KeyLength := TAESKeyLength.kl256;
FEncryption.OutputFormat := TConvertType.hexa;
FEncryption.PaddingMode := TPaddingMode.PKCS7;
FEncryption.IVMode := TIVMode.rand;
FEncryption.Unicode := TUnicode.yesUni;
FEncryption.Key := 'QFGZDJAEREFJHFVRUHOLQTSIYDPETOZJ'
end;
function TLicense.DoDecrypt(const Encryption: string): string;
var
lEncryption: string;
lConvert: TConvert;
begin
lConvert := TConvert.Create;
try
lEncryption := lConvert.ToCharString(Encryption);
try
FEncryption.outputFormat := TConvertType.raw;
Result := FEncryption.Decrypt(lEncryption);
except
// not the nicest way to handle an exception, but the user may not be aware of this
on E:ECryptoPack do
Result := '';
end;
finally
lConvert.Free;
end;
end;
function TLicense.DoEncryptKey: string;
begin
Result := FEncryption.Encrypt(User.Key);
end;
Why is the result of DoDecrypt('EF2B1D8A4414D75ECB3D9654876AD26FB793F109B5AC66C2D8AF2851285F2515') empty while the result of DoEncryptKey is exactly EF2B1D8A4414D75ECB3D9654876AD26FB793F109B5AC66C2D8AF2851285F2515 ?
What am I doing wrong here?
Regards,
Filip