obviscating python code for distribution

Rhodri James rhodri at wildebst.demon.co.uk
Mon May 16 18:42:40 EDT 2011


On Mon, 16 May 2011 03:21:00 +0100, Daniel Kluev <dan.kluev at gmail.com>  
wrote:

> On Mon, May 16, 2011 at 1:04 PM, Littlefield, Tyler  
> <tyler at tysdomain.com> wrote:
>> Hello all:
>> Finally, is there a good way to accomplish this? I know that I can make  
>> .pyc
>> files, but those can be disassembled very very easily with the  
>> disassembler
>> and shipping these still means that the person needs the modules that  
>> are
>> used. Is there another way to go about this?
>
> No, there is no way to prevent users from getting access to raw python
> sources. By its nature and design, python is not meant to be used this
> way, and even obfuscation would not harm readability much.
> However, you can write all parts you want to hide in C/C++/Cython and
> distribute them as .so/.dll

...which is, of course, not exactly secure either.  A sufficiently  
determined hacker won't have much trouble disassembling a shared library  
even if you do strip out all the debug information.  By chance I'm having  
to do something closely related to this at work just at the moment; it's  
hard, but far from impossible.

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list