Skip to content

Instantly share code, notes, and snippets.

@tatumroaquin
Created October 16, 2019 22:22
Show Gist options
  • Save tatumroaquin/8859c3f65a8452571f3f3b8bad985ece to your computer and use it in GitHub Desktop.
Save tatumroaquin/8859c3f65a8452571f3f3b8bad985ece to your computer and use it in GitHub Desktop.
#description :a simple script to perform xor operations on 2 files and save the output
#title :xor.py
#usage :xor.py file1 file2 file3
import sys
file1_b = bytearray(open(sys.argv[1], 'rb').read())
file2_b = bytearray(open(sys.argv[2], 'rb').read())
size = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b)
xord_bytes = bytearray(size)
for i in range(size):
xord_bytes[i] = file1_b[i] ^ file2_b[i]
open(sys.argv[3], 'wb').write(xord_bytes)
print("[*]", sys.argv[1],"XOR", sys.argv[2])
print("[*] Saved to", sys.argv[3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment