diff options
Diffstat (limited to 'image_processing/xor.py')
| -rw-r--r-- | image_processing/xor.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/image_processing/xor.py b/image_processing/xor.py new file mode 100644 index 0000000..01050c3 --- /dev/null +++ b/image_processing/xor.py @@ -0,0 +1,26 @@ +import sys +import math +from itertools import cycle + +source, target, key = sys.argv[1:] + +# key = [int(x) for x in key] + +k = int(key, 2) + +target = open(target,"ab") + +with open(source, 'rb') as source: + image_bytes = source.read() + i = 0 + x = 0 + for n in image_bytes: + if not (i == 3): + x = n ^ k + i += 1 + else: + x = n + i = 0 + target.write(bytes([x])) + +target.close() |
