[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem DescriptionHere's a "proof of concept" demo program implementing my ideas far an algorithm to generate program license keys when a product is purchased. The is then that can be used by the program when the program is activated or run The algorithm used here is original with me and, as far as I know, will NOT generate keys for any existing commercial programs! Background & TechniquesOverview A user recently requested a model to create a license to include purchaser's name, licensing date, and license period. Here's first cut at a method to accomplish this. I have generalized the technique by including a field definition table which provides field names, lengths, and whether the field is fixed or variable length. License keys consist of upper case letters and numbers separated by hyphen "-" characters into a fixed number of fixed size segments. Below is a screen shot of sample key definition input parameters and encryption key generation (left side) and test controls for building and decoding License Keys for a specific license (right side).
If the size of the defined data (field length sum + variable field count) is less than the desired license key length (segment size X # of segments) then consider adding additional "dummy" unused fields or expanding fixed fields by making them larger variable length fields. Encryption Key and License Key GenerationThe encryption algorithm is a simple substitution process. The 36 allowed character are randomly shuffled to generate the encryption key. The License Key generation process finds the position of each input character in the Master Key and replaces it with the character from the same position in the Encryption Key. For variable length fields, the initial character represents the number of characters required to pad the field to its specified maximum length ("A"=0, "B"-1, etc.). Than number of random characters is then added to the License Key before the encrypted field data is appended. A hyphen character is inserted every "SegSize" characters in the displayed key for ease of user entry. License Key DecryptionIn the application registration processing, the License key from the user is decoded to recreate the original data fields. These can be used to validate the license conditions and approve or deny access to the application itself. The process simply reverses the role of the Master Key and the Encryption Key. So if "A" in position 1 of the Master Key was converted to a "4" at encryption time, then a "4" in the license will be found in the 1st position of the Encryption Key and changed back to the "A" in the Master Key. Testing steps:1. Define the fields: Enter lines with formatted as "Field name"="Field
Size". Precede a field size with the letter "V" Addendum June 16, 2015: Version 1.1 corrects a few spelling
errors and improves screen formatting. As the result of being flagged as a
Trojan by the "Webroot Secure Anywhere" program, I also added the
disclaimer stating that the program will not generate a valid key for any
existing commercial program that i know of.
September September 29, 2015: Someone actually playing with the demo program uncovered a few bugs leading to the creations of Version 2.0 posted today. Errors corrected are as follows:
Encoding special characters is still a problem which might be somewhat accommodated by breaking fields containing them into multiple parts. For example "FirstName" and "LastName" in stead of a "Name" field containing both names and an embedded space. Seldom used letters or letter combinations might be implemented in a future version if they are required. September 18, 2016: Version 2.1 was posted a couple of weeks ago to add the ability to encode and decode the letter M, accidentally omitted from the previous version. So Mary Doe can now register her software just like Joe could. Version 2.2, posted today, expands data entry by removing the requirement that all defined fields be entered in the same order as they were defined. A subset of defined fields may be entered in any order. Running/Exploring the Program
Suggestions for Further Explorations
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |