Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Intro-Challenges/Labyrinth-of-Suffering/encrypt.py
1402 views
1
from Crypto.Util.number import *
2
from Crypto.PublicKey import *
3
import gmpy2
4
from secret import flag
5
6
p = getPrime(512)
7
q = getPrime(512)
8
n = p*q
9
e = 65537
10
11
s = pow(2, p-0xdeadbeef, n)
12
message = bytes_to_long(flag)
13
ciphertext = pow(message, e, n)
14
ciphertext = long_to_bytes(ciphertext)
15
ciphertext = ciphertext.encode("hex")
16
17
out_str = "[1] ciphertext: " + ciphertext + "\n[2] n: " + str(n) + "\n[3] e: " + str(e) + "\n[4] s: " + str(s)
18
obj1 = open("data.txt",'w')
19
obj1.write(out_str)
20