security.py 文件源码

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

项目:munki-enrollment-client 作者: gerritdewitt 项目源码 文件源码
def sign_message(given_message,given_key):
    '''Signs the (hash of the) given message with the given private key.
        Returns the base64 encoded signature or or a blank string if something bad happened.'''
    # Check for blank message:
    if not given_message:
        common.print_error("Cannot sign blank message.")
        return None
    # Sign the message by encrypting its hash with the private key:
    try:
        signature = crypto.sign(given_key,given_message,'sha512')
        signature = base64.b64encode(signature)
    except crypto.Error:
        common.print_error("Error signing message!")
        signature = ''
    # Return signature:
    return signature
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号