crypto.py 文件源码

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

项目:pyseeder 作者: PurpleI2P 项目源码 文件源码
def append_signature(target_file, priv_key, priv_key_password=None):
    """Append signature to the end of file"""
    with open(target_file, "rb") as f:
        contents = f.read()

    with open(priv_key, "rb") as kf:
        private_key = serialization.load_pem_private_key(
            kf.read(), password=priv_key_password, backend=default_backend())

    signature = private_key.sign(contents, padding.PKCS1v15(), hashes.SHA512())

    with open(target_file, "ab") as f:
        f.write(signature)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号