def unwrap(val): return chr((val & 0x7f)+32) + chr((val >> 7)+32) def decrypt(C, tot_sum): res = "" for i in range(15): v = tot_sum - C[i] v = v ^ ((i << 5) | i) res += unwrap(v) return res if __name__ == "__main__": C = [897, 3313, 3231, 3759, 1914, 3119, 9385, 9771, 7570, 1843, 1687, 9972, 2015, 3711, 1953] tot_sum = 11938 flag_found = decrypt(C, tot_sum) print flag_found