This project has moved and is read-only. For the latest updates, please go here.

Features can help a developer to restrict the application in several ways. SKGL supports 8 features, that may be true or false. You can for instance use one feature as an indicator of whether the key is a trial version of your software or a registered one. You can also configure different kinds of registered version keys as well.

Let us say that you are to secure your application. The objective is to create one trial version, and two registered versions. Trial is limited to 30 days, and the user cannot use certain functions. There are two kinds of registered versions, though. Both allow a user to use all functions, but, one registered version key allows only 60 days of usage. For this example, you will need to set two features only.

To add Features you need a SKGL.SerialKeyConfiguration variable. Let us define two features only: one indicates the trial version, another the time-limited-registered version, and last the unlimited-registered.

SKGL.SerialKeyConfiguration skc = new SKGL.SerialKeyConfiguration(); // adding SKC
SKGL.Generate CreateAKey = new SKGL.Generate(skc);

            
/* CREATE A TRIAL KEY */
skc.Features = new bool[8] { false, false, // indicates trial version
                             false, false,
                             false, false,
                             false, false };

string trialKey = CreateAKey.doKey(30); // creating a trial key that
                                        // will be valid in 30 days
                                        // with limited features


/* CREATE A TIME-LIMITED REGISTERED KEY */
skc.Features = new bool[8] { true, false, // indicates time-limited registered version
                             false, false,
                             false, false,
                             false, false };


/* CREATE AN UNLIMITED REGISTERED KEY */
string timeLimitedRegisteredKey = CreateAKey.doKey(60); // creating a registered key that
                                                        // will be valid in 60 days
                                                        // with all features available

skc.Features = new bool[8] { true, true, // indicates time-unlimited registered version
                             false, false,
                             false, false,
                             false, false };

string unlimitedRegisteredKey = CreateAKey.doKey(60); // creating a registered key that
                                                      // will be valid unlimited amount of time
                                                      // with all features available

As the code above illustrates, there are two features only that  are used. 

Trial version {false, false}
Time-limited registered {true, false}
Unlimited registered {true, true}

This is the most primitive way of using features for solving the problem given above. We can however extend it into three features, where each feature indicates each state/version. In our primitive method though, the first feature represent whether the program is trial or registered, and the second whether it is a time-limited registered or unlimited registered version.

SKGL.SerialKeyConfiguration skc = new SKGL.SerialKeyConfiguration(); // this variable is not affecting the result!
SKGL.Validate ValidateAKey = new SKGL.Validate(skc);

ValidateAKey.Key = textBox4.Text; // input

if (ValidateAKey.IsValid)
{
    // if the key has not been modified

    if (ValidateAKey.Features[0] == false)
    {
        // the key is a trial version of the program
        MessageBox.Show("You have limited amount of features, and only: " + ValidateAKey.DaysLeft + " day(s) left","Trial version");
     }

     if (ValidateAKey.Features[0] == true)
     {
         // the key should be a registered version (two alternatives)
         if (ValidateAKey.Features[1] == false)
         {
             // features {true, false}, which is a time-limited registered version
             MessageBox.Show("You have unlimited amount of features, and only: " + ValidateAKey.DaysLeft + " day(s) left", "Time-limited registered version");
          }
          else if (ValidateAKey.Features[1] == true)
          {
              // features {true, true}, which is a unlimited registered version
              MessageBox.Show("You have unlimited amount of features, and no time limit", "Unlimited registered version");
          }

     }
}
else
{
    // something has changed in the key
    MessageBox.Show("Invalid key. Try again!");
}

To validate your key, use the code above.

Last edited Mar 1, 2015 at 8:56 PM by artemlos, version 15