Forked from lkdocs/Python PyCrypto: Sign Data Example.py
Last active
January 22, 2018 17:53
-
-
Save pbteja1998/a6e5a4e77b90ebfb8f04a291b5cbfd34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sign_data(private_key, hashed_data): | |
''' | |
param: private_key | |
param: hashed_data SHA256 hash of data to be signed | |
return: base64 encoded signature | |
''' | |
from Crypto.PublicKey import RSA | |
from Crypto.Signature import PKCS1_v1_5 | |
from base64 import b64encode | |
key = private_key | |
rsakey = RSA.importKey(key) | |
signer = PKCS1_v1_5.new(rsakey) | |
sign = signer.sign(hashed_data) | |
return b64encode(sign) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment