PyObfusinator

A Python obfuscator code golf

print("Hello World")
Loading ...
» How does it work? «

Compression

"Compress" the code with unicode zalgo magic

Idea and implementation from this Reddit thread

Inflation

Rewrite the whole program using only 4 built-in functions: exec, eval, str, all, with (), [], and +

Numbers:

0 == all([[]])  # this equals False
1 == all([])  # this equals True
2 == all([]) + all([])
3 == all([]) + all([]) + all([])
...

Once we get the numbers down, we can use them to access any index of a string to obtain any character.


"l" == str(str)[2]    # str(str)  == "<class 'str'>"
"o" == str(eval)[16]  # str(eval) == "<built-in function eval>"
"b" == str(eval)[1]   # str(eval) == "<built-in function eval>"
...

This way, we are able to get 17 characters. With these 17 chars, we can write exec("from string import printable as b")

Finally, we can represent any printable character by accessing its index: b[idx]