Encrypt python files

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed May 6 05:04:23 EDT 2015


On Wednesday 06 May 2015 17:23, Palpandi wrote:

> On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:
>> Hi,
>> 
>> What are the ways to encrypt python files?
> 
> No, I just want to hide the scripts from others.

Why, are you ashamed of your code?

Python is free, open source software. Hiding the code from others is not a 
priority for the developers of the language. Besides, you can't hide the 
code unless you only operate the application via a web service, or similar. 
As soon as you give people a copy of the code, whether it is binary code or 
source code, they have a copy of it and can look at it and work out how what 
it does.

If "hiding the code" was good for security, why are there so many viruses 
and spybots and worms and other malware for Windows?

No, as far as I am concerned, trying to hide the code is a waste of time 
with Python. But if you absolutely must, you can distribute the .pyc files 
instead of the .py files, and that will discourage casual tinkerers from 
poking around in the program. The .pyc file is compiled to byte-code rather 
than source code, so it's not readable without running it through a 
decompiler.


-- 
Steve




More information about the Python-list mailing list