题目:
'''
n = 3454083680130687060405946528826790951695785465926614724373
e = 3
c = 1347530713288996422676156069761604101177635382955634367208
gcd(m, n) = 1
'''
from gmpy2 import *
from Cryptodome.Util.number import *
n = 3454083680130687060405946528826790951695785465926614724373
e = 3
c = 1347530713288996422676156069761604101177635382955634367208
# 对n进行分解,然后取与e互质的因数,得到新的phi和n。然后求得私钥和m
p = [17172929050033177661, 11761833764528579549, 17100682436035561357]
phi = 1
n = 1
for i in p:
if gcd(e, i - 1) == 1:
print(i)
print(i-1)
phi *= i - 1
print(phi)
n *= i
d = invert(e, phi)
print(long_to_bytes(powmod(c, d, n)))