def aes256ctr(iv, key, data):
"""
Encrypts the given data using AES-256 in CTR mode with the given IV and key.
Can also be used for decryption due to how the CTR mode works.
:param iv: The IV as a byte list.
:param key: The key as a byte list.
:param data: The data to be encrypted as a byte list.
:return: The encrypted data as a byte list.
"""
cipher = Cipher(algorithms.AES(key), modes.CTR(iv), backend = default_backend())
encryptor = cipher.encryptor()
return encryptor.update(data) + encryptor.finalize()
评论列表
文章目录