Last active
March 13, 2019 09:45
-
-
Save lkdocs/6519359 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 Crypto.PublicKey import RSA | |
from Crypto.Cipher import PKCS1_OAEP | |
from base64 import b64decode | |
key = open(private_key_loc, "r").read() | |
rsakey = RSA.importKey(key) | |
rsakey = PKCS1_OAEP.new(rsakey) | |
decrypted = rsakey.decrypt(b64decode(package)) | |
return decrypted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment