Windows Forms: Generate Serial Key in C#

Generate serial key & validate license key in C#

Step 1Click 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

c# serial keyStep 2: Right click on your project select Manage NuGet Packages -> Search SoftwareProtector -> Install

software protector in c#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.

Step 3: Design your form as below

c# license key

Step 4: Add code to button click event handler as below

private void btnGenerate_Click(object sender, EventArgs e)
{
    //Generate serial key
    SKGL.Generate generate = new SKGL.Generate();
    generate.secretPhase = txtPassword.Text;
    txtSerial.Text = generate.doKey(Convert.ToInt32(txtDay.Text));
}

private void btnValid_Click(object sender, EventArgs e)
{
    //Check valid key
    SKGL.Validate validate = new SKGL.Validate();
    validate.secretPhase = txtPassword.Text;
    validate.Key = txtSerial.Text;
    txtStatus.Text = "Creation date: " + validate.CreationDate + "\r\n" + "Expire date: " + validate.ExpireDate + "\r\n" + "Day left: " + validate.DaysLeft;
}

VIDEO TUTORIALS