crypto.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:delta-sdk-python 作者: Covata 项目源码 文件源码
def decrypt(ciphertext, tag, secret_key, initialisation_vector):
    """
    Decrypts a cipher text using the given GCM authentication tag,
    secret key and initialisation vector.

    :param bytes ciphertext: the cipher text to be decrypted
    :param bytes tag: the GCM authentication tag
    :param bytes secret_key: the key to be used for encryption
    :param bytes initialisation_vector: the initialisation vector
    :return: the decrypted plaintext
    :rtype: bytes
    """
    cipher = Cipher(algorithm=algorithms.AES(secret_key),
                    mode=modes.GCM(initialization_vector=initialisation_vector,
                                   tag=tag),
                    backend=default_backend())
    decryptor = cipher.decryptor()
    return decryptor.update(ciphertext) + decryptor.finalize()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号