diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-21 23:40:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-21 23:40:55 +0900 |
| commit | 34dd5114aa6f76ca8cfa940539f065428de23807 (patch) | |
| tree | 7125d8dbb3493e3cd86fa64a2d58786a0dc5c805 /gen.py | |
| parent | 2b514b49aec049c33cd8050d28d4bf694080f463 (diff) | |
| download | phperbiglt-2025-34dd5114aa6f76ca8cfa940539f065428de23807.tar.gz phperbiglt-2025-34dd5114aa6f76ca8cfa940539f065428de23807.tar.zst phperbiglt-2025-34dd5114aa6f76ca8cfa940539f065428de23807.zip | |
add gen.py and makefile
Diffstat (limited to 'gen.py')
| -rw-r--r-- | gen.py | 90 |
1 files changed, 90 insertions, 0 deletions
@@ -0,0 +1,90 @@ +from base64 import b64encode +from zlib import compress + +template0 = """ +from base64 import b64decode;exec(b64decode((b'~~').split(b'###')[0])) +""" +template1 = """ +from base64 import b64encode +from zlib import compress, decompress +j = b'107' +s = b"@@" +z = decompress(b64decode(s)).replace(b"j = b'%s'" % j, b"j = b'%03d'" % ((int(j)+1) % 108)) +t = z.replace(b"@"+b"@", b64encode(compress(z))) +u = b64encode(t) + +def fmt(u, f, php): + H = 10 + W = 17 + NL = b"\\n" + if php: + ss = b"<?echo zlib_decode(base64_decode(explode('###',''." + ls = b" '" + le = b"'." + NL + se = b"')[0]));" + else: + ss = b"from base64 import b64decode;exec(b64decode((b''+" + ls = b"b'" + le = b"'+" + NL + se = b"').split(b'###')[0]))" + o = ss + o += b"#" + u[0:9*W + 3 - len(ss)] + NL + i = 0 + u2 = u + b"###" + u + for y in range(9): + for dy in range(H if y%8 != 0 else H//2): + o += ls + for x in range(9*W): + if f[y][x//W] == "0": + o += b" " + else: + o += u2[i:i+1] + i += 1 + o += le + o += ls + o += u2[i:i+(9*W-len(se)+2)] + o += se + return o + +F1 = [ + "000000000", + "011111100", + "010000100", + "010000100", + "011111100", + "010000000", + "010000010", + "001111110", + "000000000", +] +F2 = [ + "000000000", + "001000000", + "001111100", + "010010000", + "000010000", + "011111110", + "000010000", + "000010000", + "000000000", +] + +v = fmt(u, F1, False) +if j == b"107": + print(fmt(b64encode(compress(v)), F2, True).decode("utf-8")) +else: + print(v.decode("utf-8")) +""" +template0 = template0.strip() + "\n" +template1 = template1.strip() + "\n" + +template0 = template0.encode("utf-8") +template1 = template1.encode("utf-8") + +template1_b64 = b64encode(compress(template1)) +replaced1 = template1.replace(b"@@", template1_b64) + +replaced1_b64 = b64encode(replaced1) +replaced0 = template0.replace(b"~~", replaced1_b64) + +print(replaced0.decode("utf-8"), end="") |
