Pistitium.Licenser
1.0.5
dotnet add package Pistitium.Licenser --version 1.0.5
NuGet\Install-Package Pistitium.Licenser -Version 1.0.5
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="Pistitium.Licenser" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pistitium.Licenser --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pistitium.Licenser, 1.0.5"
#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 Pistitium.Licenser as a Cake Addin #addin nuget:?package=Pistitium.Licenser&version=1.0.5 // Install Pistitium.Licenser as a Cake Tool #tool nuget:?package=Pistitium.Licenser&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pistitium.Licenser
Pistitium.Licenser Provides a framework to:
Provides a framework to generate unique license keys based on:
String
Hardware Identifier
- HardwareIdentity class uniquely identifies computer hardware on the running machine
Guid
Allows for generation of:
- Evaluation License Key (1 Month Expiration)
- Evaluation License Key with custom expiration
- Registration License Key (1 Year Expiration)
- Registration License Key with custom expiration
Installation
Install via Visual Studio Manage Nuget Packages... or download:
https://www.nuget.org/packages/Pistitium.Licenser
.NET CLI
> dotnet add package Pistitium.Licenser --version 1.0.X
Usage
///////////////////////////////////////////////////////////
// Sample of how to use HardwareIdentity
///////////////////////////////////////////////////////////
using Pistitium.Licenser;
public void HardwareIdentityTest()
{
try
{
Console.WriteLine("Inside HardwareIdentityTester.Run()");
Console.WriteLine();
bool regenerateLicenseFile = true;
bool doNotRegenerateLicenseFile = false;
string licensePath1 = @"F:\PistitiumLicenseFile\pistitium1.xml";
string licensePath2 = @"F:\\PistitiumLicenseFile\pistitium2.xml";
HardwareIdentity hi = new();
hi.Write(licensePath1, regenerateLicenseFile);
hi.Write(licensePath2, doNotRegenerateLicenseFile);
hi.VerifyFromXmlFile(licensePath1);
Console.WriteLine(hi.ToString());
Console.WriteLine();
Console.WriteLine(hi.GetXml());
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
// Sample Output
Inside HardwareIdentityTester.Run()
[ HardwareIdentity ]
MachineId: C85B0009AEDBB6F5FBFFD1582B4A06E976EB
MachineIdVariant: 4A0CF0QL5B76044DKCN4DBD153FFEBB5BFF0
MachineIdVariant2: 906EB76EQLHTN45WBD150B04BB5918450B04
CPU Id: BFEBFBFF000906E9
BIOS Serial: PF0QLHTN
BIOS Software Id: 4KCN45WW
Board Manufacturer: LENOVO
MAC Address: C8:5E:71:EB:B5:3C
Network Adapter GUID: FC22B4A0-C0B0-44DC-B6F5-953FF1845C8A
Hard Disk Serial: AEDBD158
<?xml version="1.0" encoding="utf-8"?><HardwareIdentity MachineId="C85B0009AEDBB6F5FBFFD1582B4A06E976EB" MachineIdVariant="4A0CF0QL5B76044DKCN4DBD153FFEBB5BFF0" MachineIdVariant2="906EB76EQLHTN45WBD150B04BB5918450B04"><Identity CpuId="BFEBFBFF000906E9" BiosSerial="PF0QLHTN" BiosSoftware="4KCN45WW" BoardManufacturer="LENOVO" MacAddress="C8:5E:71:EB:B5:3C" NetworkAdapterGuid="FC22B4A0-C0B0-44DC-B6F5-953FF1845C8A" HardDiskSerial="AEDBD158" /></HardwareIdentity>
///////////////////////////////////////////////////////////
// Create LicenseKey using HardwareIdentity
///////////////////////////////////////////////////////////
public static void GenerateKeyFromHardwareIdentity()
{
HardwareIdentity hardwareIdentity = new HardwareIdentity();
LicenseKey key = LicenseKey.Generate(hardwareIdentity, LicenseKey.KeyType.Evaluation);
Console.WriteLine($"0 : {key.Value} : {hardwareIdentity.MachineId}");
Console.WriteLine(key);
Console.WriteLine();
Console.WriteLine(key.GetXml());
}
// Sample Output
0 : ZLLJM-5085LL-336PR-44419-WTTYD : C85B0009AEDBFBFFB59AD15806E9BFEB76EB
[ LicenseKey ]
Type: Evaluation
Value: ZLLJM-5085LL-336PR-44419-WTTYD
Status: Activated
Start Date: 2023-03-02 19:36:50
Expiration Date: 2023-04-01 19:36:50
<?xml version="1.0" encoding="utf-8"?><LicenseKey Type="Evaluation" Value="ZLLJM-5085LL-336PR-44419-WTTYD" Status="Activated" StardDate="2023-03-02 19:36:50" EndDate="2023-04-01 19:36:50" />
///////////////////////////////////////////////////////////
// Create LicenseKey using Guid
///////////////////////////////////////////////////////////
public static void Display(int count, LicenseKey key, Guid guid)
{
Console.WriteLine($"Cycle: {count} : Key: {key.Value} : Guid: {guid}");
Console.WriteLine(key);
Console.WriteLine();
}
public void Run()
{
Console.WriteLine("Inside LicenseKeyTester.Run()");
Console.WriteLine();
// Use a Dictionary to see that there are no duplicates
Dictionary<string, string> keyValues = new();
try
{
int count = 1001;
for (int i = 1; i < count; i++)
{
Guid guid = Guid.NewGuid(); // Same input for evaluation and registration
LicenseKey key = LicenseKey.Generate(guid, LicenseKey.KeyType.Evaluation); // Defaults to 1 Month Expiration
Display(i, key, guid);
keyValues.Add(key.Value, guid.ToString());
key = LicenseKey.Generate(guid, LicenseKey.KeyType.Registration); // Defaults to 1 Year Expiration
Display(i, key, guid);
keyValues.Add(key.Value, guid.ToString());
guid = Guid.NewGuid(); // Same input for evaluation and registration
key = LicenseKey.Generate(guid, LicenseKey.KeyType.Evaluation, 90);
Display(i, key, guid);
keyValues.Add(key.Value, guid.ToString());
key = LicenseKey.Generate(guid, LicenseKey.KeyType.Registration, 180);
Display(i, key, guid);
keyValues.Add(key.Value, guid.ToString());
// Once the key is generated you can associate the guid and key with a customer account
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
// Sample Output
Cycle: 1000 : Key: KJKXZ-3333HK-323TY-11436-TEDTA : Guid: 7658aa7a-8d11-4947-bc3a-533715fc3b78
[ LicenseKey ]
Type: Evaluation
Value: KJKXZ-3333HK-323TY-11436-TEDTA
Status: Activated
Start Date: 2023-03-02 19:22:40
Expiration Date: 2023-04-01 19:22:40
Cycle: 1000 : Key: 676KYX-PX6DX-PV665-8DZXT-681XR : Guid: 7658aa7a-8d11-4947-bc3a-533715fc3b78
[ LicenseKey ]
Type: Registration
Value: 676KYX-PX6DX-PV665-8DZXT-681XR
Status: Activated
Start Date: 2023-03-02 19:22:40
Expiration Date: 2024-03-01 19:22:40
Cycle: 1000 : Key: KJXXJ-3366NX-493PY-44163-PRTTR : Guid: 249c27a6-aadd-45e6-94f8-caa4020ca275
[ LicenseKey ]
Type: Evaluation
Value: KJXXJ-3366NX-493PY-44163-PRTTR
Status: Activated
Start Date: 2023-03-02 19:22:40
Expiration Date: 2023-05-31 19:22:40
Cycle: 1000 : Key: 673KAX-PK3EK-CG635-5CNKP-376XA : Guid: 249c27a6-aadd-45e6-94f8-caa4020ca275
[ LicenseKey ]
Type: Registration
Value: 673KAX-PK3EK-CG635-5CNKP-376XA
Status: Activated
Start Date: 2023-03-02 19:22:40
Expiration Date: 2023-08-29 19:22:40
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows 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.
-
net6.0-windows7.0
- System.Management (>= 6.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.
Improved key generation performance.