Skip to content

Instantly share code, notes, and snippets.

@glynrob
Created October 19, 2013 18:46
Show Gist options
  • Save glynrob/7059847 to your computer and use it in GitHub Desktop.
Save glynrob/7059847 to your computer and use it in GitHub Desktop.
rsa = RSA.load_pub_key("mykey.pub")
ctxt = rsa.public_encrypt(secretstring, RSA.pkcs1_padding)
encryptedText = ctxt.encode('base64')
print 'Encrypted Text = '+encryptedText
priv = RSA.load_key("mykey.pem")
decodeEncryptedText = encryptedText.decode('base64')
decryptedText = priv.private_decrypt(decodeEncryptedText, RSA.pkcs1_padding)
print 'Decrypted Text = '+decryptedText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment