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.
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.

Troubleshooting

General

.NET specific (C#/VB.NET)

Python