Last active
March 28, 2018 07:19
-
-
Save lkdocs/6519382 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 decrypt_RSA(private_key_loc, package): | |
''' | |
param: public_key_loc Path to your private key | |
param: package String to be decrypted | |
return decrypted string | |
''' | |
from base64 import b64decode | |
from M2Crypto import BIO, RSA | |
key = open(private_key_loc, "r").read() | |
priv_key = BIO.MemoryBuffer(key.encode('utf8')) | |
key = RSA.load_key_bio(priv_key) | |
decrypted = key.private_decrypt(b64decode(package), RSA.pkcs1_oaep_padding) | |
return decrypted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment