How to protect python code ?

msw markscottwright at hotmail.com
Mon Apr 7 11:02:18 CEST 2003


Jp Calderone wrote:
> On Thu, Apr 03, 2003 at 09:35:49AM +0200, christophe grimault wrote:
> 
>>Hello,
>>
>>Before trying my own solutions, I wonder if someone already has a solution
>>to this. We have been programming a quite large application in python and
>>it contains many original algorithm and other things. The application will
>>be sent to customers in a few month and since it is a commercial app, we
>>need some protection against copy (illegal copies) and we need to make
>>sure that critical parts of the code cannot be viewed and studied.
>>

I'm really interested in this as well, and I think that it's an 
important issue for python.  Unfortunately, as I'm sure you've 
discovered by now, it's a question that comp.lang.python is 
constitionally incapable of answering.  The only answers you will get in 
this group are:

1. intellectual property law is sufficient
2. no protection scheme is perfect

People who answer #1 don't sell their product in China.  People who 
answer #2 don't understand how security works - a security scheme 
doesn't have to be perfect, it just has to be more expensive to break it 
than to purchase your product.  For most of us, distributing code in 
binary format is sufficient, even if people can theoretically de-compile 
it.  Distibuting code in .py format is not.

I think it ought to be relatively easy to distribute a hacked version of 
the python interpreter with your application that substitutes the 
standard "import" code with code that first looks for .pys files (or, 
what the hell, .tcl - let's not make this any easier) that are 
des-encrypted .py files.  Compilation to .pyo would have to be disabled, 
which would increase start-up time.  The hacked interpreter (it's pretty 
easy to embed the python interpreter in your application), could also 
check some sort of hardware token before starting.  I have no idea if 
this would violate python's license.

But unfortunately, if anyone's done this, you'll never find out about it 
on c.l.p.  :-)

Mark





More information about the Python-list mailing list