BarbezDotEu.License.Verification 3.0.0

Prefix Reserved
dotnet add package BarbezDotEu.License.Verification --version 3.0.0                
NuGet\Install-Package BarbezDotEu.License.Verification -Version 3.0.0                
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="BarbezDotEu.License.Verification" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BarbezDotEu.License.Verification --version 3.0.0                
#r "nuget: BarbezDotEu.License.Verification, 3.0.0"                
#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.
// Install BarbezDotEu.License.Verification as a Cake Addin
#addin nuget:?package=BarbezDotEu.License.Verification&version=3.0.0

// Install BarbezDotEu.License.Verification as a Cake Tool
#tool nuget:?package=BarbezDotEu.License.Verification&version=3.0.0                

Generic "Resulting-Sum" License Key Generator Library

A generator for human-friendly, readable license keys and serial numbers by www.barbez.eu.

Produces license keys you don't mind spelling out loud to another person.

The Barbez.eu license key generator is ideal for all your license key or serial number generation needs, producing keys or serials that are easy to read out loud one human to another. Yet, the algorithm is quick enough to generate a decent amount of them in a short period of time.

Table of Contents

  1. NuGet Packages and Demo app
  2. Features
  3. Custom Resulting-Sum Algorithm
  4. Performance
  5. Stats
  6. Using the Generator
  7. Using the Verifier
  8. Disclaimer
  9. Author

NuGet Packages and Demo app

Get the generator NuGet package from https://www.nuget.org/packages/BarbezDotEu.License.Generation/ or use

Install-Package BarbezDotEu.License.Generation

Get the verifier NuGet package from https://www.nuget.org/packages/BarbezDotEu.License.Verification/ or use

Install-Package BarbezDotEu.License.Verification

A demo project using this generic library can be found at https://github.com/hannesbarbez/BarbezDotEu.License.Generator.WinForms.

Features

  • Full multithreading, thanks to .NET Core’s TPL (Task Parallel Library);
  • Custom “resulting-sum” algorithm to generate a bunch of unique license keys quickly;
  • On-the-fly license key validator;
  • Decoupling, e.g. strict separation between UI and logic;
  • Generated license keys that are easy for people to spell out loud;
  • Native support for async/await.

Custom Resulting-Sum Algorithm

Lacking academic knowledge on serial number or license key generation algos, the generator algorithm is my own idea, so I’ve decided to dub it “resulting-sum”. More info on the exact workings to follow, for now the source code should suffice to explain its inner workings.

Performance

After running a couple of tests on an AMD Ryzen 1600 (6 cores, 12 threads) based machine, I compiled a short table with the results.

On this hardware, a ResultingSum of 68 takes Y time to generate X number of unique keys, and are shown in the below table.

Results will differ for other ResultingSum values. For a value of 68, about 80 000 unique keys are generated in under 5 seconds, whereas 150 000 unique keys take about 19 seconds.

Stats

Note: these stats are from version 3.0.0 of the generator, which is much faster than the initial version.

A "resulting sum" of 68 takes Y time to render/generate X number of unique keys on a Ryzen 1600 based machine.

Keys (X) Time (ms, Y) ms/key (=Y/X)
1 14 14
10 14 1.4
100 22 .22
1 000 209 .21
2 500 218 .09
5 000 402 .08
10 000 703 .07
20 000 1 472 .07
30 000 2 007 .07
50 000 3 365 .07
62 500 4 220 .07
75 000 4 867 .06
87 500 5 733 .07
100 000 6 379 .06
150 000 9 550 .06
300 000 19 291 .06
1 000 000 63 035 .06

Generator

How to use BarbezDotEu.License.Generation.

Contents

<a name='T-BarbezDotEu-License-Generation-KeyGenerator'></a>

KeyGenerator type

BarbezDotEu.License.Generation

Basic key generator class.

<a name='M-BarbezDotEu-License-Generation-KeyGenerator-#ctor-System-Int32,System-String-'></a>

#ctor(resultingSum,divider) constructor

Constructs a new KeyGenerator.

Parameters
Name Type Description
resultingSum System.Int32 The expected "sum" of the key. All keys share the same "sum", which is what makes the key validatable. Negative or default values are not valid.
divider System.String The desored division in between segments of the license key.

<a name='F-BarbezDotEu-License-Generation-KeyGenerator-EXCEPTION'></a>

EXCEPTION constants

One or more parameters are invalid. NULL, negative, empty or default values are not valid parameters.

<a name='M-BarbezDotEu-License-Generation-KeyGenerator-GenerateKeys-System-UInt32,System-String[]-'></a>

GenerateKeys(numberOfKeys,excludedKeys) method

Generates a number of license keys.

Returns

The generated license keys.

Parameters
Name Type Description
numberOfKeys System.UInt32 The amount of keys to generate.
excludedKeys System.String[] Keys that cannot be present in the resulting key set.

Verification

How to use BarbezDotEu.License.Verification.

Contents

<a name='T-BarbezDotEu-License-Verification-KeyVerificator'></a>

KeyVerificator type

BarbezDotEu.License.Verification

Basic key verifier class.

<a name='M-BarbezDotEu-License-Verification-KeyVerificator-#ctor-System-Int32,System-String-'></a>

#ctor(resultingSum,divider) constructor

Constructs a new basic key verifier (verificator, lat.)

Parameters
Name Type Description
resultingSum System.Int32 The resulting sum that has to be met for a key to be valid.
divider System.String The divider (e.g. "-") expected to be found in between different segments of a key.

<a name='F-BarbezDotEu-License-Verification-KeyVerificator-EXCEPTION'></a>

EXCEPTION constants

One or more parameters are invalid. NULL, negative, empty or default values are not valid parameters.

<a name='M-BarbezDotEu-License-Verification-KeyVerificator-ValidKey-System-String,System-String,System-String,System-String,System-String-'></a>

ValidKey() method

Checks if inputted key is valid

Returns

True if valid, false if invalid.

Parameters

This method has no parameters.

<a name='M-BarbezDotEu-License-Verification-KeyVerificator-ValidateSegment-System-String-'></a>

ValidateSegment(segment) method

Checks if a segment valid.

Returns

True if valid, false if invalid.

Parameters
Name Type Description
segment System.String The segment to interpret.

<a name='M-BarbezDotEu-License-Verification-KeyVerificator-VerifyKey-System-String,System-String,System-String,System-String,System-String-'></a>

VerifyKey() method

Checks if a key is valid as well as all of its segments.

Returns

True if the key is valid; false otherwise.

Parameters

This method has no parameters.

<a name='M-BarbezDotEu-License-Verification-KeyVerificator-VerifyKey-System-String-'></a>

VerifyKey(key) method

Verifies a given key.

Returns

TRUE if the key is valid. False, otherwise.

Parameters
Name Type Description
key System.String The key to verify.

Disclaimer

The code in this repository was written for and used within a variety of Barbez.eu apps distributed via Amazon.com in the late 2010's.

If you're looking for a license key generator that is "uncrackable", this is one is not for you (also, both generator and verificator are open source). You can however consider using it as a base for your own license key generator, perhaps.

Author

www.barbez.eu

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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
3.0.0 372 1/4/2024
2.0.0 115 1/2/2024
1.2.1 464 1/28/2021