Xor a buffer in Python
Wednesday, 11 July 2012
|
Today a little Python tip. This is not very complex, but not so intuitive due to conversions.
def xor_buffer(buf): res = '' for i in range(len(buf)): res = res + chr(ord(buf[i]) ^ 0xff) return res