Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Intro-Challenges/LoS-reloaded/encrypt.py
1402 views
1
from Crypto.Util.number import *
2
import hashlib
3
import gmpy2
4
5
p = getPrime(512)
6
q = getPrime(512)
7
n = p*q
8
print "n: ", n
9
e = 65537
10
d = inverse(e, (p-1)*(q-1))
11
print "d: ", d
12
13
hash_p = hashlib.sha256(str(p)).hexdigest()
14
hash_q = hashlib.sha256(str(q)).hexdigest()
15
16
17
# You only have access to the variables being printed on the screen when you run this program
18
print "You have two chances to get out of this labyrinth: "
19
for i in range(2):
20
p1 = raw_input("Give me p: ")
21
p2 = raw_input("Give me q: ")
22
if hashlib.sha256(p1).hexdigest() == hash_p and hashlib.sha256(p2).hexdigest() == hash_q:
23
print "Nice, you solved it. But how do you get of the labyrinth of suffering?? Getting out of it isn't easy"
24
print "You still feel trapped, don't you?"
25
break
26
else:
27
print "Oops sorry"
28