python obfuscate

Sturla Molden sturla.molden at gmail.com
Fri Apr 11 05:17:43 EDT 2014


Wesley <nispray at gmail.com> wrote:

>   Does python has any good obfuscate?
> 
> Currently our company wanna release one product developed by python to
> our customer. But dont's wanna others see the py code.
> 
> I googled for a while but mostly just say using pyc. Any better one?

It depends on the threat and how competent persons you want to protect your
code from. If this comes from your boss, chances are he does not know that
even x86 machine code can be decompiled. So as many has said, this is
mostly futile business. The only way to protect your code is never to ship
anything. 

Hacking the interpreter might be satisfactory to calm your boss:

- Run a script that strips comments and make variable names
incomprehensible
- Swap .pyc byte codes so they don't mean the same as in vanilla Python
- Make the compiler spit out scrambled bytes and make the .pyc loader
unencrypt

Any of these measures can be circumvented, though. But it is hardly easier
to read than compiled C++.

Sturla




More information about the Python-list mailing list