3

I want to protect python script, since people most likely known to be jerks and steal someones work i would really like to protect it. Its sad how easily it can be stolen... copy paste my work that i spent months in and then someone changes bits and claims it for himself.

How can i prevent anyone from seeing code? (i tried py2exe and similar, but that most often is suspicious to user since its .exe and i don't want anyone to be afraid of my software)

Linux Python2 & Python3

2
  • wiki.python.org/moin/Asking%20for%20Help/… Commented Feb 15, 2018 at 2:32
  • What do you think most programs on Windows have as their file extension on their Executable files? Commented Feb 15, 2018 at 2:32

2 Answers 2

2

There are two questions here: code protection and property. So licensing would be the second aspect, but it seems, from your question, licensing isn't your problem per-se. Some modules exist to protect your source code, like sourcedefender. It works pretty much like described by @lambda11 , though I have no idea if they use C/C++ to do their magic. The fact that they "do some magic" makes me nervous personally, code protection is one thing, but if it's a true concern, I guess the question is how hard it is to get to your code in the end. That's another story altogether. But if you look for short answers, well, people have done it previously.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem for long time. I can say the best and short solution is by two steps:

1 - encrypting your source code using sourcedefender third party here:

  • pip install sourcedefender

  • important: you must import sourcedefender as first line in main code file

  • extremely important: you must import all pip installed packages in main

    code file exactly as it's used in the project encrypted files ex: from x import y

  • encrypt any file you want using command: sourcedefender encrypt file.py

  • then : pyinstaller --onefile --add-binary encrypted code file;. app.py'

  • Note: If you have this to start your GUI:

    if name == 'main': main()

    Try this instead:

    #if name == 'main': main()

2- using software licensing APIs like: cryptolens

4 Comments

What it means: you must import all pip installed packages in main. Can I have an example?
it means if you use third party package inside any .py file in your project then you must import this package in main .py file that you use it to run your project
Hi, my question is that let's assume I have used source-defender and encrypted my file, then how can I use it in another file? Can the python interpreter also execute the .pye file extension?
Yes it can be excuted if sourcedefender is installed on your PC but if you want to use .pye on another PC withut installing python and sourcedefender then you should make an exe for your project using auto-py-to-exe package (pip install auto-py-to-exe)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.