Obfuscate brython code

93 views
Skip to first unread message

Aaron Elkins

unread,
Aug 25, 2022, 3:25:35 AM8/25/22
to brython
Hello, thank you for the great project.

I am planning to use Brython to code my project, which i don't want the code to be read easily in the production mode, so I would need some tools to obfuscate my Brython code, my python code will be in multiple .py files. If someone has suggestions which obfuscate tools to use with Brython code?

Thanks again for the project so that I can code python for browsers.

Best regards,
-Aaron

Edward Elliott

unread,
Aug 25, 2022, 3:42:23 AM8/25/22
to bry...@googlegroups.com
You picked a language that's built for readability then want to make it hard to read.  I suggest you find another language.  Try webasm.

The web is built on openness.  Obfuscators are a plague on mankind.


--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/135825c1-740f-4594-8861-db1e1b60b651n%40googlegroups.com.

Aaron Elkins

unread,
Aug 25, 2022, 3:49:57 AM8/25/22
to brython
To make this easy to understand.

My project is not open source, it's a commercial project, so I don't want my code to be easily cracked, and at least make some protection to my code. It's mainly some Brython code which use Three.js.

Sorry for not make it clear to understand.

Jonas O.

unread,
Aug 25, 2022, 4:06:08 AM8/25/22
to bry...@googlegroups.com
Since python is sensitive to line returns and indentation, I think it's a bit more difficult to obfuscate it. Anyway obfuscating python is not specific to brython, just google it.

Edward Elliott

unread,
Aug 25, 2022, 11:20:10 AM8/25/22
to bry...@googlegroups.com
The web is open source.  If you want to run your code in my browser, I get to see what it does.  That's the deal.

If your super-secret commercial code is so special, then run it on your own server.  It's your choice.  The rest of the world isn't here to prop up your flawed business model.


Evan Mallory

unread,
Aug 25, 2022, 11:36:05 AM8/25/22
to bry...@googlegroups.com
It has worked well for me to compile the Python code to JS and then obfuscate that JS. I use Javascript to load all the Python code into a single string, then call $B.python_to_js() on that string, and then obfuscate it using this project https://github.com/javascript-obfuscator/javascript-obfuscator with basically the default arguments. 

Evan


--

Aaron Elkins

unread,
Aug 25, 2022, 6:53:42 PM8/25/22
to brython
Thank you for the solution, I will try that.

dgront

unread,
Aug 26, 2022, 12:15:36 PM8/26/22
to bry...@googlegroups.com
Even more radical approach would be to write a web assembly module, e.g. in rust (easier) or in C (more complicated). A web browser receives a binary file in that case. It may be disassembled of course, but it would take tremendous effort to fully understand how the code works. In a bonus WASM is considerably faster.

Best,
Dominik

Reply all
Reply to author
Forward
0 new messages