How to Generate Serial Key in C#
By FoxLearn 12/9/2024 1:37:39 PM 9.66K
The SKGL is a lightweight .NET library that simplifies these processes. This article explains how to implement serial key generation and validation using SKGL in a Windows Forms application.
How to Implement Serial Key Generation and Validation Using SKGL Library?
Open Visual Studio, then click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "SerialKeyDemo" and then click OK
Right click on your project select Manage NuGet Packages -> Search SoftwareProtector -> Install
Software Protector is an open source 100% managed .NET licensing system based on SKGL Project. Generate keys for your software, and validate them using SKGL library in your own project.
Design your form as shown below.
The btnGenerate_Click
event handler uses the SKGL.Generate
class to create a serial key. This key is based on a secret phrase and the number of valid days provided by the user.
private void btnGenerate_Click(object sender, EventArgs e) { // Generate a serial key SKGL.Generate generate = new SKGL.Generate(); generate.secretPhase = txtPassword.Text; // Secret phrase from user input txtSerial.Text = generate.doKey(Convert.ToInt32(txtDay.Text)); // Generate the key }
The btnValid_Click
event handler uses the SKGL.Validate
class to verify the serial key. It checks the key’s validity and provides details like the creation date, expiration date, and remaining valid days.
private void btnValid_Click(object sender, EventArgs e) { // Validate the serial key SKGL.Validate validate = new SKGL.Validate(); validate.secretPhase = txtPassword.Text; // Secret phrase used during key generation validate.Key = txtSerial.Text; // Serial key to validate txtStatus.Text = "Creation date: " + validate.CreationDate + "\r\n" + "Expire date: " + validate.ExpireDate + "\r\n" + "Day left: " + validate.DaysLeft; }
VIDEO TUTORIAL
- How to update UI from another thread in C#
- How to get CheckedListBox selected values in C#
- How to use Advanced Filter DataGridView in C#
- How to create a Notification Popup in C#
- How to Use Form Load and Button click Event in C#
- How to Link Chart /Graph with Database in C#
- How to Check SQL Server Connection in C#
- How to Search DataGridView by using TextBox in C#