Last active
July 12, 2020 01:38
-
-
Save notpike/44144c1eef7ec38184365a13f1a56360 to your computer and use it in GitHub Desktop.
This file contains 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/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