Last active
June 26, 2017 14:44
-
-
Save kaminomisosiru/36527c0f072f03670d6dfe8736662854 to your computer and use it in GitHub Desktop.
decrypt RSA (PKCS1 OAEP)
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
# -*- coding : utf-8 -*- | |
def decrypt_RSA(private_key_loc, package): | |
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 | |
package = open('flag.enc', "r").read() | |
message = decrypt_RSA('private87.key', package) | |
print (message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment