LicenseGenerator 1.0.3
See the version list below for details.
dotnet add package LicenseGenerator --version 1.0.3
NuGet\Install-Package LicenseGenerator -Version 1.0.3
<PackageReference Include="LicenseGenerator" Version="1.0.3" />
<PackageVersion Include="LicenseGenerator" Version="1.0.3" />
<PackageReference Include="LicenseGenerator" />
paket add LicenseGenerator --version 1.0.3
#r "nuget: LicenseGenerator, 1.0.3"
#:package LicenseGenerator@1.0.3
#addin nuget:?package=LicenseGenerator&version=1.0.3
#tool nuget:?package=LicenseGenerator&version=1.0.3
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 viaSystem.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:
UniqueIdProcessorIdName+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.dllartifacts/LicenseGenerator.<version>.nupkg
CI/CD (Azure Pipelines)
The pipeline in azure-pipelines.yml runs on ubuntu-latest and:
- Auto-versions packages as
1.0.<patch>using an Azure DevOps build counter - Restores, builds, and packs in Release (no debug symbols in the published package)
- Verifies the
.nupkgcontains only the compiled DLL and metadata — no.cssource or.pdbfiles - Pushes to NuGet.org when the build is on
mainor av*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
- System.Management 8.0.0 — WMI access for hardware fingerprinting on Windows
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:
- Email: info@waelelazizy.com
- KSA: 0553373500
- Bahrain: 00973 33030730
<br/>
<p align="center"> <strong>Made with ❤️ for the .NET Developers</strong> </p>
<p align="center"> #DotNet #NuGet #Licensing #SerialKey #CSharp #BackOffice </p>
| Product | Versions 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. |
-
net8.0
- System.Management (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.