← Click here to go back to the list of articles

Embedding custom data in a license key

Using Secure License Manager, it is possible to embed custom data in license keys. To embed custom data in license keys, type the custom data text in the "Custom License Data" text input box and then click on the "Generate" button to generate license keys.

Custom License Data
Figure 1. Custom License Data.

The following code sample shows how to access the embedded license data at runtime during license validation using the SecureLicense.CustomData.StringValue.

using System;
using System.ComponentModel;
using System.Windows.Forms;

using SimpleMode.SecureLicenseManager;

namespace Example2
{
    public partial class TestForm : Form
    {
        private const string ValidationKey = "Type / Copy Your Validation Key Here";
        
        public TestForm()
        {
            InitializeComponent();
        }

        private void buttonCheckCustomData_Click(object sender, EventArgs e)
        {
            SecureLicense secureLicense = new SecureLicense(ValidationKey);

            secureLicense.Activate(this.textBoxLicenseKey.Text.Trim());

            if (secureLicense.IsValid)
            {
                MessageBox.Show("Custom License Data : " + secureLicense.CustomData.StringValue);
            }
            else
            {
                MessageBox.Show("License key activation failed!");
            }
        }
    }
}

                    
Imports System;
Imports System.ComponentModel
Imports System.Windows.Forms

Imports SimpleMode.SecureLicenseManager

Namespace Example2
	Public Partial Class TestForm
		Inherits Form

		Private Const ValidationKey As String = "Type / Copy Your Validation Key Here"

		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub buttonCheckCustomData_Click(sender As Object, e As EventArgs)
			Dim secureLicense As New SecureLicense(ValidationKey)

			secureLicense.Activate(Me.textBoxLicenseKey.Text.Trim())

			If secureLicense.IsValid Then
				MessageBox.Show("Custom License Data : " & secureLicense.CustomData.StringValue)
			Else
				MessageBox.Show("License key activation failed!")
			End If
		End Sub

	End Class

End Namespace

                    
                    

Listing 1. Example2 - Using custom license data at runtime.

← Click here to go back to the list of articles