P. = PolynomialRing(ZZ) f = 13*x^2 + 3*x + 7 table = {} for c in range(0x20, 0x7f): table[f.substitute(c)] = chr(c) target = [0xeba3, 0x16feb, 0xe4c5, 0x16753, 0xf9ad, 0x301bd, 0x2a0f5, 0x2267f, 0x7597, 0x2b88b, 0x2519b, 0x1fd03, 0x4db9, 0x2c47d, 0x84b5, 0x1cb71, 0x2b88b, 0x2a0f5, 0x84b5, 0x1fd03, 0x1cb71, 0x29551, 0x7597, 0x2acb3, 0x1cb71, 0x7a87, 0x84b5, 0x31af3] print("".join([table[t] for t in target]))