DownUnderCTF 2021 | Substitution Cipher 1

#joseph

#downunderctf2021

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))