1

What happens when you turn a python file into an executable? Does it get encrypted? What happens to the imported files? Can you revert it back into a normal .py file?

So I have this python file, let's call this main.py. I also have another file, let's call it scrambler.py. The scrambler.py is an encryptor/decryptor file. So, I imported it to main.py. Then I will turn it into an executable file. Now, we don't want people to see the enryptor/decryptor file. So, can people who doesn't have the source code get the source code of the imported file? Because, from searching, I saw that some people can get the source code of the main code using pyinstxtractor.py. I haven't tried it yet, but can you also get the source code of the imported file? (also do comments get included? I mean they are useless to the program). So that's why, the ultimate question: What happens when you turn a python file into an executable?

The file that I use to turn a python file into an .exe is Pyinstaller and is it different for every converter?

I hope this is a valid question. Thanks in advance.

  • Does this answer your question? [How do I protect Python code?](https://stackoverflow.com/questions/261638/how-do-i-protect-python-code) – Martheen Mar 31 '21 at 01:55
  • No, that is talking about how to make it impossible to decrypt, it answered some of the questions, like turning it into an .exe is read in binary (that's what I understood). – Tasukete Onegaishimasu Mar 31 '21 at 02:04

1 Answers1

2

Pyinstaller essentially bundles a python interpreter along with your python code in a folder. This folder can be put into an installer (using something like inno setup) to be distributed so end users can use it like a normal exe program. It doesn't compile to another language or anything. So no, your code is not private and while you can make it difficult to find certain bits, it is not impossible.

As described here, it is possible to convert to C and to machine code, but pyinstaller won't do that by default for you. Also note that the python bytecode files, while not legible, are not completely uncrackable.

See: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html See here for more about the encryption option: PyInstaller Encryption --key

atultw
  • 921
  • 7
  • 15