Question: How can I create a product key for my C# Application?

I need to create a product (or license) key that I update annually. Additionally I need to create one for trial versions.

> 
> Related:
> 
> 
> * [How do I best obfuscate my C# product license verification code?](https://stackoverflow.com/questions/501988)
> * [How do you protect your software from illegal distribution?](https://stackoverflow.com/questions/109997)
> 
> 
>

Answer: 
If you are asking about the keys that you can type in, like Windows product keys, then they are based on some checks. If you are talking about the keys that you have to copy paste, then they are based on a digitial signature (private key encryption).

A simple product key logic could be to start with saying that the product key consists of four 5-digit groups, like `abcde-fghij-kljmo-pqrst`, and then go on to specify internal relationships like f+k+p should equal a, meaning the first digits of the 2, 3 and 4 group should total to a. This means that 8xxxx-2xxxx-4xxxx-2xxxx is valid, so is 8xxxx-1xxxx-0xxxx-7xxxx. Of course, there would be other relationships as well, including complex relations like, if the second digit of the first group is odd, then the last digit of the last group should be odd too. This way there would be generators for product keys and verification of product keys would simply check if it matches all the rules.

Encryption are normally the string of information about the license encrypted using a private key (== digitally signed) and converted to [Base64](http://en.wikipedia.org/wiki/Base64). The public key is distributed with the application. When the Base64 string arrives, it is verified (==decrypted) by the public key and if found valid, the product is activated.
There are some tools and API's available for it. However, I do not think you'll find one for free ;)

There is for instance the OLicense suite:
<http://www.olicense.de/index.php?lang=en>