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 want a simple solution just to create and verify serial numbers, try [Ellipter](http://ellipter.com). It uses elliptic curves cryptography and has an "Expiration Date" feature so you can create trial verisons or time-limited registration keys.
One simple method is using a [Globally Unique Identifier](http://en.wikipedia.org/wiki/Globally_unique_identifier) (GUID). GUIDs are usually stored as 128-bit values and are commonly displayed as 32 hexadecimal digits with groups separated by hyphens, such as `{21EC2020-3AEA-4069-A2DD-08002B30309D}`.

Use the following code in C# by `System.Guid.NewGuid()`.

```
getKey = System.Guid.NewGuid().ToString().Substring(0, 8).ToUpper(); //Will generate a random 8 digit hexadecimal string.

_key = Convert.ToString(Regex.Replace(getKey, ".{4}", "$0/")); // And use this to separate every four digits with a "/".

```

I hope it helps.