Skip to content

Instantly share code, notes, and snippets.

@strategicpause
Created November 7, 2017 16:23
Show Gist options
  • Save strategicpause/48af655bd8bc011d96e1897082965784 to your computer and use it in GitHub Desktop.
Save strategicpause/48af655bd8bc011d96e1897082965784 to your computer and use it in GitHub Desktop.
from Crypto.PublicKey import RSA
from Crypto import Random
from Crypto.Cipher import PKCS1_OAEP
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash import SHA256
from base64 import b64encode, b64decode
random_generator = Random.new().read
key = RSA.generate(1024, random_generator)
digest = SHA256.new("Hello".encode("UTF8"))
signer = PKCS1_v1_5.new(key)
signature = signer.sign(digest)
print(b64encode(signature))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment