AES-128 ECB decrypt example lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- CC · 2021-01-29 01:27 Hi, as the title says it. I have looked around but I could not find anything truly useful. ---------------------------------------------------------------------- lainz · 2021-01-29 02:53 In other words Rijndael. https://wiki.freepascal.org/DCPcrypt Check that package, it has useful demos. ---------------------------------------------------------------------- trev · 2021-01-29 02:54 You didn't look very far... this post for example. ---------------------------------------------------------------------- CC · 2021-01-29 11:31 I have spent quite a few hours on this before asking and I did find the exact links provided here. Just figured that copy-pasting an example would be the least time consuming help. Faster then looking at my code. But here it is anyway. I know the format  the result should be, but it currently is gibberish. The input length is 87. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TForm1.AES128_ECB_Decrypt(AString, aKey: string): string;var  inData  : TBytes;  outData : TBytes;  StreamSize: Int64;  KeySizeInBytes, BlockSize: integer;  inStream,outStream: TStringStream;   //inStreambegin  inStream:= TStringStream.Create(AString);  StreamSize:=  inStream.Size;  outStream:= TStringStream.Create;   try     KeySizeInBytes:= 16;     BlockSize:= KeySizeInBytes;     SetLength(inData, BlockSize);     SetLength(outData, BlockSize);     //AES_Cipher := TDCP_rijndael.Create(nil); // already exists     AES_Cipher.Init(aKey , 128, nil );      While StreamSize > 0 do     begin       inStream.ReadBuffer(inData[0], BlockSize);       AES_Cipher.DecryptECB(inData[0], outData[0]);       outStream.WriteBuffer(outData[0], BlockSize);       Log(inData);     Log(outData);       Dec(StreamSize, BlockSize);       if StreamSize < KeySizeInBytes then  // Last block less then key size       begin        BlockSize:= StreamSize;          SetLength(inData, BlockSize);        SetLength(outData, BlockSize);       end;     end;     result:= outStream.DataString;   finally     inStream.Free;     outStream.Free;   end;end;                               Result: Quote??M??.?I???RM?4?(%?=?6????ro?Id??m ??)\?? NO[??5??.????܊??r>?w𷋊xլ?k ---------------------------------------------------------------------- CC · 2021-01-29 19:17 I still do not see what is wrong with the above code, but I got it working with mORMot lib SynCrypto.TAESECB. It is higher level solution, only few lines of code to use it. Base64 decoding may be necessary  first though.