Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Intro-Challenges/Challenge-3/encrypt.py
1402 views
1
from Crypto.Util.number import *
2
from secret import flag
3
4
modulus_list = [143786356117385195355522728814418684024129402954309769186869633376407480449846714776247533950484109173163811708549269029920405450237443197994941951104068001708682945191370596050916441792714228818475059839352105948003874426539429621408867171203559281132589926504992702401428910240117807627890055235377744541913L,
5
73988726804584255779346831019194873108586184186524793132656027600961771331094234332693404730437468912329694216269372797532334390363774803642809945268154324370355113538927414351037561899998734391507272602074924837440885467211134022878597523920836541794820777951492188067045604789153534513271406458984968338509L,
6
95666403279611361071535593067846981517930129087906362381453835849857496766736720885263927273295086034390557353492037703154353541274448884795437287235560639118986397838850340017834752502157881329960725771502503917735194236743345777337851076649842634506339513864285786698870866229339372558162315435127197444193L,
7
119235191922699211973494433973985286182951917872084464216722572875998345005104112625024274855529546680909781406076412741844254205002739352725207590519921992295941563460138887173402493503653397592300336588721082590464192875253265214253650991510709511154297580284525736720396804660126786258245028204861220690641L]
8
9
e = [114194L, 130478L, 122694L, 79874L]
10
message = bytes_to_long(flag)
11
ciphertext = [pow(message, e[i], modulus_list[i]) for i in range(4)]
12
ciphertext = [long_to_bytes(ciphertext[i]) for i in range(4)]
13
ciphertext = [ciphertext[i].encode("hex") for i in range(4)]
14
15
obj1 = open("ciphertext.txt",'w')
16
obj1.write(str(ciphertext))
17