Added example cli script for file obfuscation

This commit is contained in:
ChaoticByte 2024-06-24 19:10:21 +02:00
parent cbd14b6223
commit c5ff147215
No known key found for this signature in database

27
file_obf.py Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from getpass import getpass
from pathlib import Path
from obf import obf
if __name__ == "__main__":
argp = ArgumentParser()
argp.add_argument("input", help="Input file", type=Path)
argp.add_argument("output", help="Output file", type=Path)
argp.add_argument("-d", "--decrypt", help="Decrypt", action="store_true")
argp.add_argument("-i", "--iterations", help="Iterations (default: 4)", type=int, default=4)
argp.add_argument("-p", "--processes", help="Parallel processes (default: 4)", type=int, default=4)
args = argp.parse_args()
assert args.processes > 0
key = getpass("Key: ").encode()
with args.input.open("rb") as i:
with args.output.open("wb") as o:
o.truncate(0)
o.seek(0)
o.write(
obf(i.read(), key, decrypt=args.decrypt, iterations=args.iterations, processes=args.processes)
)
o.flush() # for good measure