+ genb85exec
This commit is contained in:
parent
daf84580e9
commit
e9a4f02399
27
genb85exec.py
Normal file
27
genb85exec.py
Normal file
@ -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))")
|
Loading…
Reference in New Issue
Block a user