It should be noted that it is relatively easy to decompile and reconstruct Python bytecode and remove any protection that you put into it, so you usually should not spend too much effort and time implementing protection against hacking. You just want to bet enough for people to be honest.
If you are worried that companies are buying the right amount of seats, one of the main protection mechanisms is to use the public key mechanism to digitally sign a message using the private key on your licensing server. The message is just a random string and some unique identification information that restricts the machine to a valid key for (for example, MAC address, etc.) and possibly a timestamp if you want to complete the key. This message and signature is then encoded in a line that your customers put into your program, which verify the license key, verifying that the signature matches the message and the message matches the machine.
There are simpler schemes if you don't care that the user has a key (not so that they have a different key for different machines); you can just use a completely random string for the message.
This scheme is safe if the user does not redo your code. It can be circumvented by reverse engineering the public key in your program using your own public key. It can also be circumvented by selecting information used to identify a computer, for example. MAC address falsification of this data may allow multiple installations to use the same key.
source share