Obfuscating Code in Mac App?

Hi,

I've written a program in wxPython, and I'm using py2app to compile it
as a Mac app. Since Mac apps are essentially folders, you can right-
click on the icon and select "View Contents. This leads to the
ability to read all the Python code.

While I don't particularly care about this, my client doesn't want the
code visible. Is there a way to obfuscate the code? I'm not sure
this is even a wxPython question...

Thanks in advance.

Well, you could compile all files and just leave the compiled
version on computers, however there are some tools that easily
do the back trip.

···

On Wed, 7 Dec 2011 00:35:12 -0800 (PST) tdahsu <tdahsu@gmail.com> wrote:

While I don't particularly care about this, my client doesn't want the
code visible. Is there a way to obfuscate the code? I'm not sure
this is even a wxPython question...

--
Great acts are made up of small deeds.
    -- Lao Tsu

While I think it’s silly to obfuscate one’s code, Google will help you out if you use it. For example, it led me here: http://pawsense.com/python.obfuscator-0002/ or http://stackoverflow.com/questions/576963/python-code-obfuscation

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

It's not.

IN generaly, Python is not a good choice if code obsucation is important -- personally, I think code obsucatin i never important, but...

Options,none of which are very robust:

1) Ship only the *.pyc files- I think py2app can do that, but not sure, but you could post-process the app bundle if you want.

Note that a lot of the code is actually in a zip file -- not quite right out there, but agreed, that's barely hidden.

2) You could use Cython as a sort-of code obfuscator -- it compiles python to C, then you compile that. It'll speed up the code a bit (or a lot, if you do some optional static typing, etc), and then the user gets compiled C instead of python. Probably not worth all the effort, but you could do some of the "key" modules, and maybe make your client happy.

-Chris

···

On 12/7/11 12:35 AM, tdahsu wrote:

I've written a program in wxPython, and I'm using py2app to compile it
as a Mac app. Since Mac apps are essentially folders, you can right-
click on the icon and select "View Contents. This leads to the
ability to read all the Python code.

While I don't particularly care about this, my client doesn't want the
code visible. Is there a way to obfuscate the code? I'm not sure
this is even a wxPython question...

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Hi Chris,

Sorry to hijack the thread, but is there a lot of work to supply
to really accelerate the program or does it stay quite trivial,
and does it work with whatever code?

JY

···

On Wed, 07 Dec 2011 10:56:59 -0800 "Chris.Barker" <Chris.Barker@noaa.gov> wrote:

2) You could use Cython as a sort-of code obfuscator -- it compiles
python to C, then you compile that. It'll speed up the code a bit (or a
lot, if you do some optional static typing, etc), and then the user gets
compiled C instead of python. Probably not worth all the effort, but you
could do some of the "key" modules, and maybe make your client happy.

--

Really questions for the Cython list, but...

In theory, Cython can handle any Python code -- in practice, it handles most ( I think ).

But in it's raw state, all you are getting is the python turned into calls to the cpython run time, so little performance change.

With the static typing, performance can improve a lot, but it depends a lot on the code -- simple numeric code sees radical improvements. Calls to wxPython, for instance, probably none.

Cython can also be used to call C libraries -- a major use-case.

-Chris

···

On 12/7/11 11:23 AM, Jean-Yves F. Barbier wrote:

2) You could use Cython as a sort-of code obfuscator -- it compiles
python to C, then you compile that. It'll speed up the code a bit (or a
lot, if you do some optional static typing, etc)

Sorry to hijack the thread, but is there a lot of work to supply
to really accelerate the program or does it stay quite trivial,
and does it work with whatever code?

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov