diff --git a/genb85exec.py b/genb85exec.py new file mode 100644 index 0000000..6e51b26 --- /dev/null +++ b/genb85exec.py @@ -0,0 +1,27 @@ +import base64 +import sys + +WIDTH = 80 +PREFIX = 4 + + +def split_encoded(bytes_str: str, width: int): + for i in range(0, len(bytes_str), width): + yield bytes_str[i : i + width] + + +sys.stdin.reconfigure(encoding="utf-8") +code = sys.stdin.read().strip() +code = str(base64.b85encode(code.encode("utf-8"))) +code = code[:-1] + +print(f"{' ' * PREFIX}code = (") +first = True +for line in split_encoded(code, WIDTH - PREFIX): + if first: + print(f"{' ' * (PREFIX + 4)} {line}'") + first = False + else: + print(f"{' ' * (PREFIX + 4) } + b'{line}'") +print(f"{' ' * PREFIX})") +print(f"{' ' * PREFIX}exec(__import__('base64').b85decode(code))")