from Crypto.Util.number import *
from flag import flag

flag = bytes_to_long(flag)
p = getPrime(80)
q = getPrime(80)
n = p * q
e = 65537
print(n)
phi = (p - 1) * (q - 1)
d = inverse(e, phi)
cipher = pow(flag, e, n)
print(cipher)
flag = pow(cipher, d, n)
flag = long_to_bytes(flag)
print(flag)
with open("cipher.txt", "w") as f:
    f.write(f"n = {n}\n")
    f.write(f"e = {e}\n")
    f.write(f"cipher = {cipher}\n")