1

I have this piece of code

import hashlib
from Cryptodome.Cipher import AES
decryption_key = hashlib.sha256(b"050746" + b"\x00\x00\x00\x03").digest()
iv = 16 * b '\x00'
aes = AES.new(decryption_key, AES.MODE_CBC, iv)
decrypted_nonce = aes.decrypt(encrypted_nonce)

I need help in understanding what this code is doing

I would be grateful for your help

Qwetroman
  • 11
  • 3
  • 1
    The code firstly builds a byte array (b"05...), generates a SHA256 value of that data, uses the hash as (decryption) key for AES algorithm in CBC mode. CBC requires an additional parameter called "initialization vector" that is fixed to a byte array filled with 16 x00's. The value in "encrypted_nonce" is then decrypted to the variable "decrypted_nonce". – Michael Fehr Mar 22 '21 at 21:32
  • Thank you, now I understand – Qwetroman Mar 23 '21 at 09:31

0 Answers0