AESKey: TAESKey256 = ($67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67, $67);
AESIV: TAESBuffer = ($68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68, $68);
(AESKey = 32 x "g" and AESIV = 16 x "h")
function Encrypt(data : string) : String;
var
S : String;
begin
S := IntToHex(Length(Data), 16);
Result := AESEncryptString(S + Data, AESKey, AESIV);
end;
function AESEncryptString(Data : AnsiString; Key : TAESKey256; IV : TAESBuffer) : AnsiString;
var
Cipher: TDCP_rijndael;
I: Integer;
begin
Cipher := TDCP_rijndael.Create(nil);
Cipher.Init(Key[0], 256, @IV[0]);
if (Length(Data) mod 16 > 0) then //this fix is less than 16
for I := 1 to (16 - (Length(Data) mod 16)) do
Data := Data + AnsiChar(0);
SetLength(Result, Length(Data));
Cipher.EncryptCBC(Data[1], Result[1], Length(Data));
Cipher.Burn;
Cipher.Free;
end;