42 lines
932 B
Python
42 lines
932 B
Python
from Cryptodome.Util.number import bytes_to_long, getPrime
|
|
#from secret import flag
|
|
def egcd(a, b):
|
|
if (a == 0):
|
|
return (b, 0, 1)
|
|
else:
|
|
g, y, x = egcd(b%a, a)
|
|
return (g, x - (b//a) * y, y)
|
|
|
|
e = 65537
|
|
|
|
"""p, q = getPrime(64), getPrime(64)
|
|
n = p*q
|
|
e = 65537
|
|
print(n)
|
|
m = bytes_to_long(flag)
|
|
print(pow(m, e, n))"""
|
|
|
|
#p = 14364722473065221639
|
|
#q = 12271643243945501447
|
|
|
|
p = 88824237363878748201253577036
|
|
q = 866961515596671343895614356197
|
|
|
|
n = p*q
|
|
phi = (p-1)*(q-1)
|
|
res = egcd(e, phi)
|
|
|
|
#c = 46228309104141229075992607107041922411
|
|
|
|
c = 388435672474892257936058543724812684332943095105091384265939
|
|
u = res[1]
|
|
v = res[2]
|
|
|
|
decrypted = pow(c,u,n)
|
|
|
|
print(decrypted.to_bytes(decrypted.bit_length()//8+1,byteorder='big').decode())
|
|
#P20 = 14364722473065221639
|
|
#P20 = 12271643243945501447
|
|
# 176278749487742942508568320862050211633
|
|
# 46228309104141229075992607107041922411
|