How protect proprietary Python code? (bytecode obfuscation?, what better?)

Daniel Nogradi nogradi at gmail.com
Tue Apr 18 06:36:53 EDT 2006


> >> char secret_code[] = "print 'moshe'";
> >>
> >> int main()
> >> {
> >>     return PyRun_SimpleString(secret_code);
> >> }
> >>
> >> and you need to link with python24.lib or whatever the object file is
> >> for your platform.
> >
> > Are you sure? On a linux platform I tried linking with libpython2.4.so
> > (I assume this is the correct object file) but it segfaults in
> > PyImport_GetModuleDict( ).
>
> I still don't understand why you think that embedding the *source code* in a
> variable
> named "secret" will do a better job than just putting the byte code in some
> non-obvious
> packaging, but if you insist on embedding the code, reading the
> documentation might
> help:
>
>     http://docs.python.org/ext/embedding.html
>     "At the very least, you have to call the function Py_Initialize()"
>
>     http://docs.python.org/ext/high-level-embedding.html
>     (minimal PyRun_SimpleString example)

Well, I was not the original poster in this thread I just picked up
the idea of executing python code that is assigned to a string from
within C and tried to do it with no particular goal, that's all. And
thanks a lot for the links, the docs are pretty clear, I should have
checked them before....



More information about the Python-list mailing list