def xor_bytes(data):
accumulator=0
if isinstance(data, int):
string = data.to_bytes(1, byteorder='big')
accumulator ^= (ord(string) & 0xff)
elif isinstance(data, str):
data = data.encode('cp1251')
for char in data:
accumulator ^= (ord(char.to_bytes(1, byteorder='big')) & 0xff)
else:
raise Exception('Invalid type')
return accumulator