summaryrefslogtreecommitdiff
path: root/logical_operators/and.py
diff options
context:
space:
mode:
authorroot <root@annapurna.annapurna.fitness>2025-07-09 16:06:10 +0200
committerroot <root@annapurna.annapurna.fitness>2025-07-09 16:06:10 +0200
commit72cb72a14dd0f64b1cd861057b61266dfc10bb76 (patch)
tree9f0988b12bbede1436583e5d9ddd40314d4d3582 /logical_operators/and.py
initial commit
Diffstat (limited to 'logical_operators/and.py')
-rw-r--r--logical_operators/and.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/logical_operators/and.py b/logical_operators/and.py
new file mode 100644
index 0000000..7e6a352
--- /dev/null
+++ b/logical_operators/and.py
@@ -0,0 +1,18 @@
+from sys import argv
+
+# 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 = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b)
+andd_byte_array = bytearray(size)
+
+# AND between the files
+for i in range(size):
+ andd_byte_array[i] = file1_b[i] & file2_b[i]
+
+# Write the ANDd bytes to the output file
+open(argv[3], 'wb').write(andd_byte_array)
+
+print(f"[*] {argv[1]} AND {argv[2]}\n[*] Saved to \033[1;33m{argv[3]}\033[1;m.")