Created
May 2, 2025 08:39
-
-
Save UserUnknownFactor/e330bcff8b84ac6f86a822939d149ce4 to your computer and use it in GitHub Desktop.
Revisions
-
UserUnknownFactor created this gist
May 2, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import os import numpy as np import re def xor_files(key_string, extension=".txt", prefix="dec_", bytes_required=6): key_bytes = bytes([int(x, 16) for x in key_string.split()]) #assert len(key_bytes) == bytes_required, f"Key must be exactly {bytes_required} bytes" # Get all files in the current directory all_files = [f for f in os.listdir() if f.lower().endswith(extension)] for filename in all_files: print(f"Processing {filename}...") with open(filename, 'rb') as f: data = np.frombuffer(f.read(), dtype=np.uint8) # Create the key array and repeat it to match the data length key_array = np.array(list(key_bytes), dtype=np.uint8) repeats = len(data) // len(key_array) + 1 full_key = np.tile(key_array, repeats)[:len(data)] result = np.bitwise_xor(data, full_key) output_filename = f"{prefix}{filename}" with open(output_filename, 'wb') as f: f.write(result.tobytes()) print(f"Created {output_filename}") # Example usage if __name__ == "__main__": key = "AA BB CC DD EE FF" xor_files(key)