Code Room
Code reviewMediumcr-g562
Subject Crypto securityLevel Mid–Senior~25 minCommon in Security interviewsIndustries Software development

Question

Review this Python encryption helper.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
from Crypto.Cipher import AESfrom Crypto.Util.Padding import pad, unpad def encrypt_blob(key: bytes, plaintext: bytes) -> bytes:    # key is 32 bytes, validated by the caller    cipher = AES.new(key, AES.MODE_ECB)    return cipher.encrypt(pad(plaintext, AES.block_size)) def decrypt_blob(key: bytes, ciphertext: bytes) -> bytes:    cipher = AES.new(key, AES.MODE_ECB)    return unpad(cipher.decrypt(ciphertext), AES.block_size) # Used to encrypt user profile records before storing in S3blob = encrypt_blob(master_key, profile.SerializeToString())
Run or narrate your approach, then ask the coach.