Skip to content

Instantly share code, notes, and snippets.

@Rurik
Last active August 7, 2025 16:56
Show Gist options
  • Select an option

  • Save Rurik/11223222 to your computer and use it in GitHub Desktop.

Select an option

Save Rurik/11223222 to your computer and use it in GitHub Desktop.
Generic code to do a multi-byte XOR encoding
# Python 2
def multibyte_xor(data, key):
from itertools import izip, cycle
return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
# Python 3
def multibyte_xor(data, key):
from itertools import cycle
return bytes([b ^ k for b, k in zip(data, cycle(key))])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment