summaryrefslogtreecommitdiff
path: root/xor.py
diff options
context:
space:
mode:
authorroot <root@annapurna.annapurna.fitness>2025-07-09 16:07:39 +0200
committerroot <root@annapurna.annapurna.fitness>2025-07-09 16:07:39 +0200
commitdf59764861742648ccc1dd27388cd95703d3080a (patch)
tree56351af27175560e35da0bd06ce5dc503143ec4e /xor.py
parent72cb72a14dd0f64b1cd861057b61266dfc10bb76 (diff)
changed folder structure & deleted useless filesHEADmaster
Diffstat (limited to 'xor.py')
-rw-r--r--xor.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/xor.py b/xor.py
new file mode 100644
index 0000000..17bd630
--- /dev/null
+++ b/xor.py
@@ -0,0 +1,23 @@
+from sys import argv
+"""
+0 + 0 -> 1
+1 + 1 -> 1
+0 + 1 -> 0
+1 + 0 -> 0
+"""
+# Read two files as byte arrays
+file1_b = bytearray(open(argv[1], 'rb').read())
+file2_b = bytearray(open(argv[2], 'rb').read())
+
+# Set the length to be the smaller one
+size = min(len(file1_b), len(file2_b))
+xord_byte_array = bytearray(size)
+
+# XOR between the files
+for i in range(size):
+ xord_byte_array[i] = file1_b[i] ^ file2_b[i]
+
+# Write the XORd bytes to the output file
+open(argv[3], 'wb').write(xord_byte_array)
+
+print(f'[*] {argv[1]} XOR {argv[2]}\n[*] Saved to \033[1;33m{argv[3]}\033[1;m.') \ No newline at end of file