cse_6.py 304 B

1234567
  1. def encrypt_cbc(aes_key, content):
  2. iv = os.urandom(16)
  3. padder = PKCS7(AES.block_size).padder()
  4. padded_result = padder.update(content) + padder.finalize()
  5. aescbc = Cipher(AES(aes_key), CBC(iv)).encryptor()
  6. result = aescbc.update(padded_result) + aescbc.finalize()
  7. return result, iv