You are not logged in.
Pages: 1
Hello, I need AES 256 ecb encryption. I do encryption, but the result is different from online editors. What's the problem
function EncryptItAES(const s: string; const AKey: TBytes): string;
var
Key: TSHA256Digest;
Aes: TAESECB;
_s: RawByteString;
begin
Result := EmptyStr;
Key := SHA256Digest(Pointer(AKey), Length(AKey));
Aes := TAESECB.Create(Key, 256);
try
_s := StringToUTF8(s);
_s := Aes.EncryptPKCS7(_s, False);
_s := BinToBase64(_s);
Result := UTF8ToString(_s);
finally
Aes.Free();
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
Enc: TEncoding;
Key : TBytes;
s : String;
begin
Enc := TEncoding.ANSI;
Key := Enc.GetBytes('Xk1891Js3TdaGNiXdFboGLOXHfLF0exu');
Memo1.Lines.Text := EncryptItAES('deneme',Key);
end;
Pages: 1