LicenseGenerator 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package LicenseGenerator --version 1.0.3
                    
NuGet\Install-Package LicenseGenerator -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LicenseGenerator" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LicenseGenerator" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="LicenseGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LicenseGenerator --version 1.0.3
                    
#r "nuget: LicenseGenerator, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LicenseGenerator@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LicenseGenerator&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=LicenseGenerator&version=1.0.3
                    
Install as a Cake Tool

LicenseGenerator

A .NET 8 NuGet library for software licensing workflows: generate formatted serial keys, derive a machine fingerprint from Windows hardware (WMI), and hash license data for validation or storage.

Published as the LicenseGenerator package by BackOffice. The library ships as a compiled assembly only (no source or debug symbols in the published package).

Features

Capability Method Platform
Alphanumeric serial keys (GUID-based, hyphen-separated) GetSerialKeyAlphaNumaric Any
Numeric serial keys GetSerialKeyNumaric Any
Machine / CPU fingerprint requestKey Windows only
MD5 hash with formatted hex output GetHash Any

Requirements

  • .NET 8.0 or later
  • Windows — required only for requestKey() (uses WMI via System.Management)
  • Serial key and hashing APIs work on any platform supported by .NET 8

Install

From NuGet.org (after the package is published):

dotnet add package LicenseGenerator

From a local build:

dotnet build -c Release
dotnet add package LicenseGenerator --source ./bin/Release

Quick start

The namespace and the main static class are both named LicenseGenerator. Use a type alias to avoid ambiguity:

using LG = LicenseGenerator.LicenseGenerator;

// Generate a 16-character key as 4 groups of 4: e.g. "A1B2-C3D4-E5F6-7890"
string serial = LG.GetSerialKeyAlphaNumaric(segment: 4, digits: 4);

// Windows only: fingerprint the current machine's CPU
string machineKey = LG.requestKey();

// Hash a license string (e.g. serial + machine key) for storage or comparison
string licenseHash = LG.GetHash($"{serial}-{machineKey}");

API reference

GetSerialKeyAlphaNumaric(int segment, int digits)

Generates an uppercase alphanumeric serial key derived from a new Guid.

  • Total length = segment × digits
  • Supported total lengths: 16, 18, 20, 24, 28, 32 (enforced via SNKeyLength)
  • Format: characters grouped with - separators (groups of 3 or 4 depending on length)
Call Total chars Example shape
(4, 4) 16 XXXX-XXXX-XXXX-XXXX
(6, 3) 18 XXX-XXX-XXX-XXX-XXX-XXX
(5, 4) 20 XXXX-XXXX-XXXX-XXXX-XXXX
(6, 4) 24 XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
(7, 4) 28 XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
(8, 4) 32 XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
string key = LG.GetSerialKeyAlphaNumaric(4, 4);
// e.g. "F3A9-1B2C-8D4E-7F01"

GetSerialKeyNumaric(SNKeyNumLength keyLength)

Generates a numeric-only serial key of fixed length.

string shortKey  = LG.GetSerialKeyNumaric(SNKeyNumLength.SN4);   // 4 digits
string mediumKey = LG.GetSerialKeyNumaric(SNKeyNumLength.SN8);   // 8 digits
string longKey   = LG.GetSerialKeyNumaric(SNKeyNumLength.SN12);  // 12 digits

requestKey() (Windows only)

Returns a hardware fingerprint for the current machine by querying WMI Win32_Processor. The method tries, in order:

  1. UniqueId
  2. ProcessorId
  3. Name + Manufacturer + MaxClockSpeed (fallback chain)

Use this to bind a license to a specific machine or to include a machine identifier in license validation logic.

#if WINDOWS
string cpuFingerprint = LG.requestKey();
#endif

Note: Mark calling code with [SupportedOSPlatform("windows")] or guard with platform checks. On non-Windows runtimes, calling this method is not supported.

GetHash(string input)

Computes an MD5 hash of the input string (ASCII encoding) and returns an uppercase hexadecimal string with a - inserted after every 4 hex characters.

string hash = LG.GetHash("my-license-data");
// e.g. "A1B2-C3D4-E5F6-7890-ABCD-EF01-2345-6789"

Enums

public enum SNKeyLength   { SN16 = 16, SN18 = 18, SN20 = 20, SN24 = 24, SN28 = 28, SN32 = 32 }
public enum SNKeyNumLength { SN4 = 4, SN8 = 8, SN12 = 12 }

Typical licensing workflow

A common pattern when building activation or license validation:

using LG = LicenseGenerator.LicenseGenerator;

// 1. Issue a serial key to the customer
string serial = LG.GetSerialKeyAlphaNumaric(4, 4);

// 2. On the client machine (Windows), collect hardware fingerprint
string machineId = LG.requestKey();

// 3. Combine and hash for storage or offline validation
string activationPayload = $"{serial}|{machineId}";
string activationCode = LG.GetHash(activationPayload);

// 4. Store serial, machineId, and activationCode in your license database

Your application is responsible for persisting keys, validating hashes, and enforcing license terms. This library provides the generation and fingerprinting primitives only.

Project structure

LicenseGenerator/
├── LicenseGenerator.cs      # Static API (serial keys, WMI fingerprint, hashing)
├── LicenseGenerator.csproj  # NuGet package metadata and dependencies
├── LicenseGenerator.sln     # Solution file
├── azure-pipelines.yml      # CI/CD: build, pack, verify, publish to NuGet.org
└── README.md

Build locally

dotnet restore
dotnet build -c Release
dotnet pack -c Release -o ./artifacts

The Release build produces:

  • bin/Release/net8.0/LicenseGenerator.dll
  • artifacts/LicenseGenerator.<version>.nupkg

CI/CD (Azure Pipelines)

The pipeline in azure-pipelines.yml runs on ubuntu-latest and:

  1. Auto-versions packages as 1.0.<patch> using an Azure DevOps build counter
  2. Restores, builds, and packs in Release (no debug symbols in the published package)
  3. Verifies the .nupkg contains only the compiled DLL and metadata — no .cs source or .pdb files
  4. Pushes to NuGet.org when the build is on main or a v* tag

Triggers: pushes to main and release/*, tags matching v*, and pull requests to main.

Publishing setup

To enable NuGet.org push from the pipeline, add a secret pipeline variable in Azure DevOps:

Variable Type Description
NUGET_API_KEY Secret API key from nuget.org with push scope for LicenseGenerator

Create the key at nuget.org → Account → API Keys → Create. Enable Keep this value secret when adding it to the pipeline variables.

Dependencies

Platform support summary

API Windows Linux / macOS
GetSerialKeyAlphaNumaric Yes Yes
GetSerialKeyNumaric Yes Yes
GetHash Yes Yes
requestKey Yes Not supported

<h2>📞 Support</h2>

For issues or questions, please contact us:

<br/>

<p align="center"> <strong>Made with ❤️ for the .NET Developers</strong> </p>

<p align="center"> #DotNet   #NuGet   #Licensing   #SerialKey   #CSharp   #BackOffice </p>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 95 5/20/2026
1.0.4 86 5/20/2026
1.0.3 90 5/20/2026
1.0.2 91 5/20/2026