CTFlearn-Writeups/Cryptography/RSA Beginner/Flag.py

18 lines
395 B
Python
Raw Permalink Normal View History

2020-07-31 18:48:25 +05:30
import gmpy2
from gmpy2 import mpz
e=mpz(3)
c=mpz(219878849218803628752496734037301843801487889344508611639028)
n=mpz(245841236512478852752909734912575581815967630033049838269083)
#use factordb
q=mpz(416064700201658306196320137931)
p=mpz(590872612825179551336102196593)
phi=gmpy2.mul(p-1,q-1)
d=gmpy2.invert(e,phi)
f=gmpy2.powmod(c,d,n)
g=bytes.fromhex(hex(f)[2:])
print("[+] Flag is : ",g)