Created
July 13, 2014 12:12
-
-
Save nk0t/06a9212c9c4b2a482c1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
_ = 1 | |
__ = 2 | |
___ = 4 | |
____ = 8 | |
_____ = 16 | |
______ = 32 | |
_______ = 64 | |
""" | |
def pack(s): | |
code = '_=()==();__=_+_;___=__+__;____=___+___;_____=____+____;______=_____+_____;_______=______+______;' | |
r = [] | |
for c in s: | |
n = ord(c) | |
r.append('+'.join(['_'*(i+1) for i in range(7) if n&(1<<i)])) | |
p = ','.join(r) | |
code += 'exec("%c"*{})%({})'.format(len(s),p) | |
print code | |
def main(): | |
if len(sys.argv) > 1: | |
f = open(sys.argv[1]) | |
pack(f.read()) | |
f.close() | |
else: | |
print 'usage: pypack.py file' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment