Last active
June 15, 2016 10:45
-
-
Save ihaveamac/52d133097afa9e36a4c2812b0663fe84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import sys | |
if len(sys.argv) != 3: | |
print("xor.py <file> <xorpad>") | |
sys.exit() | |
encfile = open(sys.argv[1], "rb") | |
xorpad = open(sys.argv[2], "rb") | |
outfile = open("%s.out" % sys.argv[1], "wb") | |
encfile_c = encfile.read() | |
xorpad_c = xorpad.read(len(encfile_c)) | |
xored = "" | |
for byte_f, byte_x in zip(encfile_c, xorpad_c): | |
xored += chr(ord(byte_f) ^ ord(byte_x)) | |
outfile.write(xored) | |
encfile.close() | |
xorpad.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment