Distributing closed source modules
fuzzyman at gmail.com
Fri Mar 25 10:21:35 CET 2005
Dave Brueck wrote:
> Jiri Barton wrote:
> Protecting code in any language is pretty tough and/or futile, but
> Google the archives if you're interested in reading more on that.
It's certainly something lot's of people are interested in. I guess it
depends who your audience is. If ytour code isn't for *mass*
distribution - the chances of people putting a lot of effort into
breaking it are greatly reduced. I don't htink it's necessarily futile.
> Anyway, you can create a module on the fly like this (untested):
> import new, sys
> name = 'MyModule'
> m = sys.modules[name] = new.module(name)
> exec codeStr in m.__dict__
> where codeStr is a string that contains the source code of your
> from file('somemodule.py').read() ).
This is one of the better solutions I've seen. (Probably because it's
*not* very complex). The stored modules can be well encrypted.
Obviously the decryption code will be in the main code - but I guess it
can be obfuscated pretty well.
I like it.
> You can combine the above with whatever mechanism you come up with
> distributing the code itself. You could store it in an encrypted
> you could download it on the fly from a remote server over a secure
More information about the Python-list