Skip to content

Instantly share code, notes, and snippets.

@lkdocs
Last active March 13, 2019 09:45
Show Gist options
  • Save lkdocs/6519359 to your computer and use it in GitHub Desktop.
Save lkdocs/6519359 to your computer and use it in GitHub Desktop.
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