Archived

This topic is now archived and is closed to further replies.

Monty Python

Protecting Python Code

Recommended Posts

I''ve recently started to learn Python and am wondering if there are any good methods to protect the source code when distributing programs. The only way I know is to force the user to sign a legal document before using the program/script but that isn''t very practical. Has anybody got any ideas?

Share this post


Link to post
Share on other sites
Why give away the source code at all? If you don't want anyone to see it, just don't ship it. just ship the .pyc files.

[edited by - VolkerG on July 2, 2003 6:10:25 PM]

Share this post


Link to post
Share on other sites
You are WAY too paranoid. If your program is any good (which we can assume it will be since you''re planning on distributing it to a lot of people), then people will know about it. Release it under the GPL, and then if someone wants to use it, that''s fine. They will have to publish their source code too. That''s the POINT of open source. You release some code, someone else sees what you did and they improve it. You see what they did, you improve it, etc. That is a GOOD THING.

Go here and pick whichever viewpoint you''re coming from (business, consumer, hobbyist) and read about the benefits of open source. There are really very few reasons to not release what you have as open source, especially if it''s going to mean you have to do extra work to avoid making it open source.

Share this post


Link to post
Share on other sites
quote:
Original post by Russell
Release it under the GPL, and then if someone wants to use it, that''s fine. [...] There are really very few reasons to not release what you have as open source, especially if it''s going to mean you have to do extra work to avoid making it open source.

One of those reasons - not entirely uncommon - is the desire to make money by selling your programs. That''s rather difficult with a licence that allows other people to redestribute them for free. Don''t get me wrong, I like open source software, but I also have a certain measure of understanding for people who don''t want to give away the fruits of their labour.

Share this post


Link to post
Share on other sites
You could always try using Jython to compile your stuff to Java .class files.

edit: Oh yeah, instead of preaching OSS goodness (which is indeed good) let's stick to answering his question.

I'm hip because I say "M$" instead of "MS".

[edited by - the speed bump on July 2, 2003 9:09:30 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by the Speed Bump
You could always try using Jython to compile your stuff to Java .class files.

Uh, that won''t help much. Reverse engineering .class files is pretty easy.



AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.

Share this post


Link to post
Share on other sites
Reverse engineering (when pre-obfuscated in Java's case) tends to produce source code like "int f061(*c017 o044, *c022 o045)". In any program of sufficient size, it's plenty of work to make it look like a human's. I wouldn't worry about it being passed off as someone else's; they could claim they obfuscated it themselves, but few people would buy that.

I will second the GPL route. Even total strangers in the open source scene will not pass up a chance to torture, kill and devour the bodies of those who would dare steal GPLed code.

[edited by - Sakuranbo on July 2, 2003 10:21:55 PM]

Share this post


Link to post
Share on other sites
.pyc files are relatively easily decompiled.

Just don''t. If you try, it''ll look like you have something to hide, which means you have something of value, which means people will try harder.

Really, the best way is to fool your audience into thinking that they are not using Python code, and thus don''t know to look for the source.

Or you could rewrite the parts you have to hide as a module, and import that into your Python scripts, which will have relatively little of importance. From the sound of it, though, you don''t actually have anything worth stealing (i.e. interesting, nonobvious bits of code), just something that might be worth pirating, so it''s probably not worth the bother.

Distributing the source to scripting parts of code is not unheard of. BBS programs are typically written in perl and distributed in source code. In the case of Python, Paint Shop Pro 8 uses Python for scripting, and distributes the sources to several files.

Share this post


Link to post
Share on other sites
quote:
Original post by Monty Python
I''ve recently started to learn Python and am wondering if there are any good methods to protect the source code when distributing programs.

The only good way to protect your intellectual investment (whatever the language) is through recourse to the law. Slap a copyright notice on your programs. Of course, one might ask why you care about anyone stealing your source-code? Unless there really is an intellectual investment to be protected, I''d suggest pasting-in a standard notice saying that your source can be distributed and used freely as long as your work is attributed via copying and pasting the same notice into derivative works. Something like a BSD licence.
quote:

The only way I know is to force the user to sign a legal document before using the program/script but that isn''t very practical.

Isn''t it? I''ll wager you have to `sign'' a legal document for much of the stuff you download from the ''net. It appears to be fairly practical.

Share this post


Link to post
Share on other sites