def encrypt(self, cleartext: bytes):
# No need for padding as we are using GCM
# Get a new iv for GCM
iv = urandom(int(AES.block_size // 8))
cipher = Cipher(self._hazmat_key, GCM(iv), backend=openssl)
encryptor = cipher.encryptor()
enc = encryptor.update(cleartext) + encryptor.finalize()
return iv + enc + encryptor.tag
评论列表
文章目录