The procedure TAESGCM.SetKey
looks to me like you described as the final solution:
procedure TAESGCM.SetKey(const Value: string);
var
Conv: TConvert;
begin
Conv := TConvert.Create(inputFormat);
if Value <> '' then begin
The procedure TAESEncryption.SetKey
is missing the InputFormat
.
procedure TAESEncryption.SetKey(const Value: string);
var
s: string;
Conv: TConvert;
begin
if inputFormat <> raw then begin
Conv := TConvert.Create;
I have now only tested it with my code, but the error message about the key length still appears.
When I run my original code, I no longer get the ‘-208’ error message, however the key length is still being objected to.
Addition:
The ‘-208’ error has reappeared; it was probably just coincidence earlier.
function Tdm.DecryptStr(AString: String): String;
begin
try
var Conv: TConvert;
Conv := TConvert.Create(hexa);
AES.AType := atCBC;
AES.KeyLength := kl256;
AES.OutputFormat := hexa;
// AES.Key := Conv.FormatToChar(FKey);
AES.Key := FKey;
AES.PaddingMode := TPaddingMode.PKCS7;
AES.IVMode := TIVMode.rand;
AES.Unicode := yesUni;
Result := AES.Decrypt(Astring);
except
on E:Exception do
begin
Showmessage(E.ClassName+': '+E.Message);
end;
end;
end;
I think there are still other places that need to be adjusted.