rsa.py 文件源码

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

项目:Cryptical 作者: mathieudev 项目源码 文件源码
def rsa_sign(priv_key, payload):
    """Sign the payload.

    This function sign the payload using RSA-PSS algorithm and private key
    of the source.

    :parameter:
     priv_key : RSA key object
        The rsa private key use to sign the payload.
     payload : string
        The payload to sign.

    :return: A string, the RSA-PSS signature of the payload.
    """

    # prepare the SHA256 hash
    h = SHA256.new()
    # create the SHA256 hash of the payload
    h.update(payload)
    # prepare the PKCS1-PSS signature with the private key
    signer = PKCS1_PSS.new(priv_key)
    # sign the hash
    thesignature = signer.sign(h)

    return thesignature
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号