def squarer(value, key): if len(value) % 2 == 0: p = int(round(len(value)) / 2.0) value = reversed(value[-p:]) + reversed(value[:p]) k = 0 result = '' for v in value: if ord(v) ^ ord(key[k]) < 32 | ord(v) ^ ord(key[k]) > 126 | ord(v) < 0 | ord(v) > 255: result += v else: result += chr(ord(v) ^ ord(key[k])) k = 0 if k == len(key) else k + 1 return result