Obfuscating code by changing the variable names to underscores
# fib.pyfromoperatorimportaddclassFibber(object):
@staticmethoddeffib(n):
a, b=0, 1foriinxrange(n):
a, b=b, add(a, b)
returnbprintFibber.fib(10)# _fib.py
(___________, ____________, _____________) = (0, 1, 10)
(________, _________, __________) = (object, xrange, staticmethod)
fromoperatorimportaddas_class__(________):
@__________def___(____):
(_____, ______) = (___________, ____________)
for_______in_________(____):
(_____, ______) = (______, _(_____, ______))
return______
(fib,) = (___,)
print__.fib(_____________)
(Fibber, add) = (__, _)pip install underscore
Support for python2.6 and python2.7
Usage: _ [options] src [dest]
Options:
-h, --help show this help message and exit
-o, --original write out the original file as a comment to the compiled
code
-v, --verbose
You can also compile through python
fromunderscoreimport__(filename, output_filename)python setup.py develop
make test
tests/compile_test.py- This test makes sure that all argument combinations for the comandline tool works properly
tests/diff_test.py- This test compiles python files in
example/intoexample/underscoredthen runs both version to check that their outputs are equivalent.
- This test compiles python files in
tests/meta_test.py(Not ready yet)- This test will turn the source code into underscored code, then with the underscored code we will turn the source code into underscored code again.. and check that the
sourceandoutputare the same.. I know mind blowing..
- This test will turn the source code into underscored code, then with the underscored code we will turn the source code into underscored code again.. and check that the
- Give out warnings if users are using
execas this may lead to incorrect behavior. - Write the
meta_test.pydescribed above. - Module doc-string to work
