Search code examples
pythonhtmlcssserver-side

How to protect my Python program


What I want to do is protect a Python program from being stolen by people with no computer knowledge. I accept the inevitability of the program being pirated, all I want to do is protect it from average users.

I have come up with two ideas. 1.)Set a time restriction by checking online for the date and time. I.E. 10 days from downloaded time. 2.)Checking the IP or Name of the computer that downloaded it and make the program only runs on that computer. (to prevent friends from simply sharing the file).

The problem with both of these is that I'll need to create a .py file "on the fly" and then use something like pytoexe to make it into an .exe so that the user doesn't need to have Python installed.

The problem with the second is that to my understanding ip's change and getting the computer name is a security risk and might scare away users.

So to sum it up, here are my two questions: 1.) Is there a good way in python to only allow the program to run on that single computer? 2.) What is the best way to implement a "on the fly" creation of the exe? (I was going to host the website on my computer and learn php(?)/servers.

I have moderate c/c++ and basic html/css, java, and python experience.

Thank you for your time!


Solution

  • Give each user a customized installer that has a unique key in it. When it runs, it contacts a server (with the key) and requests the actual program. Server-side, you check if the key is valid and if so, serve the program customized with the key, and mark the key as used. The installer saves the program somewhere the user can access it, and creates a hidden file that contains the key somewhere deep in the bowels of the computer, where the "average user" won't think of looking. When the program is run, the first thing it does is check if the hidden file exists and if it contains the correct key, and refuses to run if not.

    (I am assuming that unzipping an executable and reading source code is beyond the ability of the "average user" (read: "grandma"), so using py2exe is ok.)