def crypt_bytes_key(key_bytes,
data_bytes,
is_encrypt_flag=None,
iv_bytes=None,
algorithm=ciphers_algorithms.AES,
mode=ciphers_modes.CTR):
'''
Use symmetric key encryption to encrypt or decrypt data_bytes with
key_bytes.
Returns the crypted data_bytes.
See crypt_create() and crypt_bytes_context() for details.
'''
crypt_context = crypt_create(key_bytes,
is_encrypt_flag=is_encrypt_flag,
iv_bytes=iv_bytes,
algorithm=algorithm,
mode=mode)
(_, crypt_bytes) = crypt_bytes_context(crypt_context, data_bytes)
return crypt_bytes
评论列表
文章目录