Path: blob/master/RSA-encryption/Intro-Challenges/LoS-reloaded/encrypt.py
1402 views
from Crypto.Util.number import *1import hashlib2import gmpy234p = getPrime(512)5q = getPrime(512)6n = p*q7print "n: ", n8e = 655379d = inverse(e, (p-1)*(q-1))10print "d: ", d1112hash_p = hashlib.sha256(str(p)).hexdigest()13hash_q = hashlib.sha256(str(q)).hexdigest()141516# You only have access to the variables being printed on the screen when you run this program17print "You have two chances to get out of this labyrinth: "18for i in range(2):19p1 = raw_input("Give me p: ")20p2 = raw_input("Give me q: ")21if hashlib.sha256(p1).hexdigest() == hash_p and hashlib.sha256(p2).hexdigest() == hash_q:22print "Nice, you solved it. But how do you get of the labyrinth of suffering?? Getting out of it isn't easy"23print "You still feel trapped, don't you?"24break25else:26print "Oops sorry"2728