The code below should be included whenever you want to verify a license key, which normally occurs during app start (eg. Form_Load for desktop apps). In addition, you can invoke it whenever a user updates the license key. In some licensing models, this check needs to be called periodically.

Getting started

1

Add client SDK/library

First, we need to install the client SDK / library

Install Nuget package

In Visual Studio package manager
PM> Install-Package Cryptolens.Licensing
Using dotnet CLI
dotnet add package Cryptolens.Licensing
If you are targeting Mac, Linux or Unity/Mono, we recommend to use the cross platform version of that package.In Visual Studio package manager
PM> Install-Package Cryptolens.Licensing.CrossPlatform
Using dotnet CLI
dotnet add package Cryptolens.Licensing.CrossPlatform
2

Add namespace

using SKM.V3;
using SKM.V3.Methods;
using SKM.V3.Models;
3

Add key verification script

The following script will verify the license key with the server. To get it to work, you need to change the ProductId, the RSAPubKey, Access Token and licenseKey. More information can be found below the code snippet.
var licenseKey = "GEBNC-WZZJD-VJIHG-GCMVD"; // <--  remember to change this to your license key
var RSAPubKey = "enter the RSA Public key here";

var auth = "access token with permission to access the activate method";
var result = Key.Activate(token: auth, parameters: new ActivateModel()
{
    Key = licenseKey,
    ProductId = 3349,  // <--  remember to change this to your Product Id
    Sign = true,
    MachineCode = Helpers.GetMachineCodePI(v: 2)
});

if (result == null || result.Result == ResultType.Error ||
    !result.LicenseKey.HasValidSignature(RSAPubKey).IsValid())
{
    // an error occurred or the key is invalid or it cannot be activated
    // (eg. the limit of activated devices was achieved)
    Console.WriteLine("The license does not work.");
}
else
{
    // everything went fine if we are here!
    Console.WriteLine("The license is valid!");
}

Console.ReadLine();
.NET(C#/VB.NET) only: If your application will run in Unity/Mono, Rhino/Grasshopper or on a platform other than Windows, we recommend to use a different version of Key.Activate.
RSAPubKey is found at the bottom of this page, under RSA Public Key section and it’s the same for the entire account. You don’t need to change it.Access token can be created on this page. For the code to work, please check “Activate” permission and leave other fields unchanged. Typically, an access token stays the same for all your products, however, you can always create a new one and make it product specific.ProductId is found on the product page and if you add the key verification script to a new product, this value needs to be changed in the code.LicenseKey is found on the product page and contains 20 characters of the following format AAAA-BBBB-CCCC-DDDD. Each end user/customer should normally receive their unique license key. The license key should not be hard coded inside the application. Instead, there should be a way for the user to enter it inside the application or other means.
Using license keys is only one of the way to authenticate customers. You can also use license files (see Offline verification tutorial for more information) as well as username and password (see User verification tutorial).

Troubleshooting

General

.NET specific (C#/VB.NET)

Python

C++

How errors are reported in the C++ library is described in the README.md file, which is also available here.