Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2019 14:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
XORient Yourself
#!/usr/bin/env python2
def xor(msg, key):
o = ''
for i in range(len(msg)):
o += chr(ord(msg[i]) ^ ord(key[i % len(key)]))
return o
with open('message', 'r') as f:
msg = ''.join(f.readlines()).rstrip('\n')
with open('key', 'r') as k:
key = ''.join(k.readlines()).rstrip('\n')
assert key.isalnum() and (len(key) == 9)
assert 'TUCTF' in msg
#NOTE: I am sharing the hex digest not the raw as indicated here
with open('encrypted', 'w') as fo:
fo.write(xor(msg, key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment