Good day!
Creating my first commercial application, I began to think about a system that would protect it from unauthorized copying, and indirectly help me control its sales. I myself am a programmer and have no experience in sales, and at the software distribution stage, I wanted to attract specially trained people for this. For this, I developed a special licensing system for my software. As it turned out to me later, no one will promote your software after creation until it becomes known and works without errors. So you need to learn to sell as well as programming. And the licensing system has remained, and I hope that in the future it will still play its role in software distribution.
In general, I want to talk about the licensing system that I developed for my software. Suddenly, some ideas will be useful to someone in order to get more money for their applications. This system does not claim to be completely protected, but it is a very good protection against a fool.
Let's not make ourselves angels and patrons. All programmers want to get a decent cash equivalent for their programs.
Those. The objectives for creating a licensing system were:
1. Installation control software, free and not free
2. Ability to make software suddenly paid
3. Control of software functionality
Those. the task from itself to itself was put such:
4. Software should not work without receiving an activation key.
5. The activation key should not be stored in software distributions and cannot simply be calculated (it is possible to calculate, but not simply)
6. Software should not run if it is patched.
7. The activation key must be associated with only one running software instance.
8. Ability to change activation keys after software update
9. Ability to limit the activation key's time
10. The activation key must carry information about the modules involved in the program.
')
At once I will make a reservation that the software for which the licensing system was developed is a program for sales. It uses MS SQL DBMS. It is planned to distribute this software through the Internet, as a free version and through merchants for money. The free version is supposed to disable some functionality, and if the client decides to use the full version, then he can purchase it.
After some time, the general scheme of the licensing system was as follows:

It all starts with the fact that the user receives the software. Software can be obtained by downloading it from the program site. Next, installs it on its server and DBMS workstations. After installation, the program does not start, but asks to enter an activation key.
In general, activation can be performed in two ways:
1. Activate software as free
2. Activation of software received through the seller
Before describing the steps for software activation, I will briefly describe how to prepare it first.
Before creating a distribution kit and starting to distribute software, after compilation, changes and additional information are made to its binary file and database. This is primarily a software version, and permission to run some modules. Critical parts of the code are also encrypted. The encryption key is known only to the software provider that created the release.


Well, now the activation itself. The activation mechanism is as follows:
1. Customer receives software.
2. Software installation
3. First software launch
4. Getting the registration code of the program
5. Getting the activation code
6. Restarting the program
But to get the activation code, you need to transfer the registration code of the program to the software provider. The activation code can be obtained both from the activation server, which is located on the Internet, and manually, by contacting the software provider by mail or phone.

The registration code of the program creates an activation code. For this, the initial data for obtaining the activation code are transferred via the registration code: program release, hard disk or network card number, database ID.
Also, to create an activation code, you need a software encryption key. When activated as free software via the Internet, the encryption key is “sewn up” into the activation code through the mechanisms on the activation server.
If the client receives an activation code through the seller, the seller then requests it from you (ie, the software supplier), then to transfer it to the client. For one application, my process of obtaining an activation code through the seller was also automated. An account was created for each vendor in the licensing system, where he could receive activation codes for software.
Here is the application interface that generates the activation codes:

Interface for obtaining an activation code via the Internet with limited functionality:

The resulting activation code contains a key by which critical parts of the code are encrypted. As soon as the activation code enters the program's database, it starts to work.
It seems that the idea is simple, but it all turned out to be a little more complicated than I expected. Especially, probably, because when implementing the server part of the licensing system, I had to get acquainted with the peculiarities of creating extensions for PHP, “pumping” into C programming, and generally find out what the Unix platform is closer to (on the hosting where the licensing system is installed FreeBSD ). This is a magical world ... The choice for Unix was made for economic reasons. Hosting Unix is ​​15 times cheaper than Windows. The server is, and does not ask for food.
The licensing system used libraries OpenSSL. Without encryption anywhere.
This is my first post on Habré. If people have more specific technical questions on this licensing system, I will be happy to try to answer them.
Everyone has more working applications and more denyushek.
Thanks for attention.