def encrypt(msg, f): return ''.join(chr(f.substitute(c)) for c in msg) P.<x> = PolynomialRing(ZZ) f = 13*x^2 + 3*x + 7 FLAG = open('./flag.txt', 'rb').read().strip() enc = encrypt(FLAG, f) print(enc)
P.<x> = PolynomialRing(ZZ) f = 13*x^2 + 3*x + 7 with open("output.txt") as fp: cs = fp.read().strip() flag = [] for c in cs: m = (f - ord(c)).roots() flag.append(m[0][0]) print(bytes(flag))