Select to view content in your preferred language

Best way to obfuscate python code?

3858
1
03-13-2013 01:24 PM
KatharinaPalffy-Gelfand
Emerging Contributor
Hi, what is the best way to prevent someone from reading and editing python code?
I tried py2exe, pyinstaller and cx_freeze to create an executable. I got the executables, but they don't run.
I also looked into compiling the .py file into a .pyc file, but found on the internet, that these files are relatively easy to decompile.
Is importing and password protecting the script my only option? And how safe is that?
Thanks
Tags (2)
0 Kudos
1 Reply
MathewCoyle
Honored Contributor
Depending on how dedicated the person attempting to get to your source code, there really is no foolproof way. Any system or password can be cracked given the time, resources, and willingness to do it.

http://stackoverflow.com/questions/261638/how-do-i-protect-python-code

Using a .pyc and maybe include a licensing agreement should be sufficient for most cases.
0 Kudos