首页 > 其他 > 详细

官方提供的AEAD_AES_256_GCM解密方法

时间:2021-03-17 14:54:16      阅读:684      评论:0      收藏:0      [点我收藏+]
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import base64

def decrypt(nonce, ciphertext, associated_data):
    key = "Your32Apiv3Key"

    key_bytes = str.encode(key)
    nonce_bytes = str.encode(nonce)
    ad_bytes = str.encode(associated_data)
    data = base64.b64decode(ciphertext)

    aesgcm = AESGCM(key_bytes)
    return aesgcm.decrypt(nonce_bytes, data, ad_bytes)

官方提供的AEAD_AES_256_GCM解密方法

原文:https://www.cnblogs.com/mrzhao520/p/14548253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!