I am creating a Dash Multipages App and have the following folder directory:
| app.py
| .\pages → page_1.py, page_2.py
Does anyone have any suggestion on how I would obfuscate my code in page_1.py and page_2.py while ensuring that the app still runs? Any help is appreciated! Thanks in advance!
I think we’d need more information on what you are attempting. Python, by nature, wasn’t really designed to be obfuscated since one of it’s major pillars is ease of use and readability.
Are you obfuscating to hide secrets? Is the code a secret? Legal reasons? Don’t wanna share your toys ? haha
Hey @tphil10@AIMPED! Thanks for your response! Unfortunately, this is a part of a client’s requirement for legal reason. And yes, what I mean by ‘code obfuscation’ is trying to safeguard the source code so that it’s not easily copied by those who gets access to it.
You are going to have a particularly hard time accomplishing this task. Even if you did a python exe file, that can still be reverse engineered pretty easily. Python is simply not designed to be obfuscated or hidden, it’s really designed to be shared and easily read.
Since you are building out a dashboard (i presume since you are here), I would either build out a SaaS solution and give out the result of the dashboard/analytics that way they can’t see the code or just have the people your giving the code to sign NDA’s so they can’t legally talk about/reveal it. You can definitely deploy dash applications in a wide range of ways.
Disclaimer: I am not a lawyer and my opinion should not be taken as legal advice.
Just to circle the loop here. I ended up not encrypting my Dash app codes. Instead, I encrypted the backend files which are considered IP. For anyone wondering what encryption package I used, I used sourcedefender: sourcedefender · PyPI
An alternative to sourcedefender for Python code obfuscation is to use PyArmor.
You can generate licenses with expiry date, use different levels of obfuscation, etc.
There is a free and a paid version for more advanced features.