#1 2019-03-13 19:10:54

keinn
Member
Registered: 2014-10-20
Posts: 103

How to Encrypt/Decrypt with AESECB?

input string data:"mORMot is awesome!", password is "123"

the result AESECB with pkcs5padding hex result should be :
"1d35c8513d106079e66c1f13a0e57eb5d96f97231f345b07bd42ae6d9dd02694"

is there some Decrypt wrapper function like :
function DecryptAesEcbFromHexString(const HexStr,Password:RawUtf8):RawUTF8;

or Encrpyt string to Hex string like:
function AesEcbEncryptAsHex(const Str,Password:RawUtf8):RawUTF8;

can u show some pieces of code please?
thank you very much .

Offline

#2 2019-03-13 20:57:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: How to Encrypt/Decrypt with AESECB?

Did you try TAESECB.EncryptPKCS7 / TAESECB.DecryptPKCS7 ?

But you need to know how the password is hashed.

Offline

#3 2019-03-14 05:43:36

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: How to Encrypt/Decrypt with AESECB?

How about SimpleEncrypt?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2019-03-15 01:12:10

keinn
Member
Registered: 2014-10-20
Posts: 103

Re: How to Encrypt/Decrypt with AESECB?

var
  ret:rawbytestring;
  display:rawutf8;
begin
aes:=TAESECB.Create('123',128);
try
  ret :=aes.EncryptPKCS7('mORMot is awesome!');
  display :=BinToHex(ret);
finally
  aes.free;
end;
end;

here the display result is 76D7EC0CD8E8EACA15F8214126A62D3A7C503EB0820B52233986FF917554669C
it is wrong.
when use 128 KeySize , the result should be 1d35c8513d106079e66c1f13a0e57eb5d96f97231f345b07bd42ae6d9dd02694

Offline

#5 2019-03-15 01:25:20

keinn
Member
Registered: 2014-10-20
Posts: 103

Re: How to Encrypt/Decrypt with AESECB?

i know that now, the key also should uses some digest method to generate

Offline

#6 2019-05-13 03:02:17

delphi_911
Member
Registered: 2018-06-11
Posts: 31

Re: How to Encrypt/Decrypt with AESECB?

keinn wrote:
var
  ret:rawbytestring;
  display:rawutf8;
begin
aes:=TAESECB.Create('123',128);
try
  ret :=aes.EncryptPKCS7('mORMot is awesome!');
  display :=BinToHex(ret);
finally
  aes.free;
end;
end;

here the display result is 76D7EC0CD8E8EACA15F8214126A62D3A7C503EB0820B52233986FF917554669C
it is wrong.
when use 128 KeySize , the result should be 1d35c8513d106079e66c1f13a0e57eb5d96f97231f345b07bd42ae6d9dd02694

How to generate the key in this case? Many thanks!

Offline

#7 2019-05-13 07:53:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: How to Encrypt/Decrypt with AESECB?

It depends on the algorithm used on your reference code, to compute the 128-bit key from the input password.
We can't tell it from our side. smile

Offline

#8 2019-05-13 11:24:27

rastafarey
Member
Registered: 2019-05-13
Posts: 2

Re: How to Encrypt/Decrypt with AESECB?

Hola buen día.
Estoy intentando enviar una imagen usando
TWinHTTP.Post(Url, data, '', true, Nil);
pero no entiendo como cargar una imagen al parámetro data.
Si alguien me podría indicar como hacerlo.

Con TNetHTTPClient lo he realizado usando TMultipartFormData, pero me gustaría usar mORMot.

Gracias por su ayuda.

Offline

Board footer

Powered by FluxBB