from Crypto.Util.number import long_to_bytes, bytes_to_long

N = 14109079294121299269372327102345698281661151418484717238877903559809682063731479750264886654253765570615859154324343623986689267177255980599161523297118651277319471185482666857432303837221757755323908917907976739955034661371119965050227323962648962698200328182576801458662936245334644632501249544981364318128754470231601899415995604205213051153596819089711880371274363941541188680964328460330649123083441491930667080735562939115993248483591882084770891188071397561047287847053296250752911592936988102532700517134492773957504992117692330428155938968174883711737704023446956224516656190277226059670381612320069285116867
e = 65537

def encrypt(flag: bytes):
    m = bytes_to_long(flag)
    ct = pow(m, e, N)
    return ct

def decrypt(ct: int, p: int, q: int):
    phi = (p-1)*(q-1)
    d = pow(e, -1, phi)
    pt = pow(ct, d, N)
    return long_to_bytes(pt)

# encrypted flag:
# ct = 10551889864422154852505364548960885213089682284501275676620373293724050678638277253542062339004839938002830665659680987387453609424639286835325100028090131672365225812877836048710596062949545126102401051900048945400867988673942903003152121055054532683036892257513152575556930429414456936094843955142230708908906644132065136718809831245126432715417344268153253890962115686154687765662907477003403465000145676513636339623513028654094273830286399862853871559482040755076685137173228125410522363679512670954050250912395237252111791511920990058951751225038144549464805868727599634397371336450923921021427899250479285159524
