from Crypto.Cipher import AES
from Crypto.Util.number import inverse as inv
from hashlib import md5,sha512
username = 'KCTF'
N = 47722871591096725757997518891734102017424753321232253627204800066229728054329
P = 201522792635114097998567775554303915819
Q = 236811285547763449711675622888914229291
assert(P*Q==N)
e = 65537
d = inv(e,(P-1)*(Q-1))
key = b'H\x0bb\xc3\xac\xd6\xc8\xa3k\x18\xd9\xe9\x06\xcd\x90\xd2'
ci = AES.new(key,AES.MODE_ECB)
hashed_un = md5(sha512(username.encode()+b'\xde\xed\xbe\xef').digest()).digest()
hashed_un = md5(sha512(hashed_un+b'\xb9\x79\x37\x9e').digest()).digest()
assert(len(hashed_un)==16)
x = hashed_un.rjust(32,b'\x00')
x = list(x)
x[0]=0
x[1]=2
x[15]=0
x = bytes(x)
# print(x)
x = int(x.hex(),16)
# print(hex(x))
x = pow(x,d,N)
x = bytes.fromhex(hex(x)[2:].rjust(64,'0'))
ct = ci.encrypt(x)
print(ct.hex())