Skip to content

Instantly share code, notes, and snippets.

@notpike
Last active July 12, 2020 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notpike/44144c1eef7ec38184365a13f1a56360 to your computer and use it in GitHub Desktop.
Save notpike/44144c1eef7ec38184365a13f1a56360 to your computer and use it in GitHub Desktop.
#! /usr/bin/python3
import sys
#MainUnit
key = b'\x7a\x49\x1e\xeb\x33\x28\x2b\x8b\x84\xa7\xad\x47\xb8\x31\x03\xd0'
def main():
fileIn = open(str(sys.argv[1]), "rb")
fileOut = open("file.out", "ab")
try:
chunk = fileIn.read(16)
while(chunk):
for byte, bKey in zip(chunk, key): ## Foreach threw chunk and key and XOR their values
xorByte = byte ^ bKey
#xorByte = xorByte ^ bKey ## Integrity Check
#print(bytes([xorByte])) ## My Welfare Check
fileOut.write(bytes([xorByte]))
chunk = fileIn.read(16)
finally:
fileIn.close()
fileOut.close()
if(__name__ == "__main__"):
if(len(sys.argv) !=2):
print("Usage: ./xor_file.py <fileName>")
exit()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment