Hack Forums
[Python] Can i encrypt my python program code? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Can i encrypt my python program code? (/showthread.php?tid=5795206)



Can i encrypt my python program code? - DrollBeack18100 - Feb 5, 2018

Can i encrypt my python program code , so if i gave it to someone he might change the credits and pretend that he is the one who made this program.


RE: Can i encrypt my python program code? - Riԁdle - Feb 5, 2018

I don't think you can "truly" encrypt a python program, but you can do

Code
python -OO -m py_compile yourFile.py
in the terminal and it will produce folder and in that folder there is a file that contains byte code, it's probably reversible I haven't looked much into it but it should work, also don't forget to rename the file extension back to .py from .pyc


RE: Can i encrypt my python program code? - DrollBeack18100 - Feb 5, 2018

(Feb 5, 2018 05:08 AM)Riԁdle Wrote:  I don't think you can "truly" encrypt a python program, but you can do

Code
python -OO -m py_compile yourFile.py
in the terminal and it will produce folder and in that folder there is a file that contains byte code, it's probably reversible I haven't looked much into it but it should work, also don't forget to rename the file extension back to .py from .pyc

Thank you so much .. 🤝


RE: Can i encrypt my python program code? - Charger - Feb 5, 2018

(Feb 5, 2018 05:08 AM)Riԁdle Wrote:  I don't think you can "truly" encrypt a python program, but you can do

Code
python -OO -m py_compile yourFile.py
in the terminal and it will produce folder and in that folder there is a file that contains byte code, it's probably reversible I haven't looked much into it but it should work, also don't forget to rename the file extension back to .py from .pyc

As far as I know, that is as good as it gets. Only other option would be to run it as a SAAS application.


RE: Can i encrypt my python program code? - DrollBeack18100 - Feb 6, 2018

(Feb 5, 2018 01:32 PM)Charger Wrote:  As far as I know, that is as good as it gets. Only other option would be to run it as a SAAS application.

What do you mean by SAAS application?


RE: Can i encrypt my python program code? - Charger - Feb 6, 2018

(Feb 6, 2018 02:53 PM)DrollBeack18100 Wrote:  What do you mean by SAAS application?

As in Software as a Service. You host the app and then clients hit it via an API (normally).


RE: Can i encrypt my python program code? - DrollBeack18100 - Feb 7, 2018

Thank you all 🤝 . Does this code 'python -OO -m py_compile yourFile.py' can decrease the probability of detecting the malware?
And how can we decrypt it back?


RE: Can i encrypt my python program code? - Charger - Feb 7, 2018

(Feb 7, 2018 02:13 AM)DrollBeack18100 Wrote:  Thank you all 🤝 . Does this code 'python -OO -m py_compile yourFile.py' can decrease the probability of detecting the malware?
And how can we decrypt it back?

Nope, if anything it might increase the chance of false positives. This will probably only occur with lower-end anti-viruses.


RE: Can i encrypt my python program code? - SerCoDev - Feb 12, 2018

(Feb 5, 2018 05:08 AM)Riԁdle Wrote:  I don't think you can "truly" encrypt a python program, but you can do

Code
python -OO -m py_compile yourFile.py
in the terminal and it will produce folder and in that folder there is a file that contains byte code, it's probably reversible I haven't looked much into it but it should work, also don't forget to rename the file extension back to .py from .pyc


Thank you for this! simple to the point solution to a problem I was having the other day.


RE: Can i encrypt my python program code? - Wiked™ - Apr 24, 2018

You could also encrypt your code as a string, then use 'exec(string)', though doing so could be problematic as you would also need to include the decryption key within the source