Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python AES ECB
#1
Hi,

I'm very new to python and I have a question about AES.
I have to use a function in both python and PHP which uses AES/ECB crypto, but couldn't get the equivalent output.
The following code is my starting point:

  from Crypto.Cipher import AES
...
  path = text.encode("utf-8")
  h = MD5.new(path)
  path_hash = h.digest()
  aes = AES.new(aes_key, AES.MODE_ECB)
  signing = aes.encrypt(path_hash)
  signing = heylify(signing)
  signing = signing.decode("utf-8")
I tried to get the same result with php openssl_encrypt, but none of the cryptos resulted the same.

Any help would be greatly appreciated.

István
buran write Oct-05-2021, 10:34 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
The solution was:
bin2hex(openssl_encrypt(openssl_digest($bemenet,'md5',true), 'aes-256-ecb', $key, OPENSSL_RAW_DATA));
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020