Click here to Skip to main content
15,884,892 members
Articles / Programming Languages / C++
Alternative
Article

License Key Generation

Rate me:
Please Sign up or sign in to vote.
4.63/5 (10 votes)
7 Mar 2014CPOL2 min read 41K   5.7K   54   1
This is an alternative for "License Key Generation"

Introduction

The set of sources for automate generation of license keys for software products, allows using string templates of keys with set of required key tokens, checksum values for determining authenticity of generated keys and random data for security reasons.

Concepts

For generation of license key, it is needed to create a string of license template and add to each token of template initial value. Fields in license key template sting follow sequentially and marked by any choose symbol, as 'n', 'f', 'k' and so on. It is demonstrated in the screenshot of FullTest mode of demo program.

Background

The key fields represent random data and checksums (that are built in library), number of products or article, parts of serial number, version of product, type of used licensing, date of license issue and duration of it, number of allowed runs or views, license expiration date, number of licensed workstations, comment to license, program runs options, etc.

Using the Code

This example shows how simple automate generation of license keys in program:

C++
GenerateKey    gkey;
gkey.LicenseTemplate(_T("pppx-000x-1111-vvxx-xxss-rrrr-xxcc"));
gkey.MaxTokens(6);
gkey.AddToken(0, 'p', NUMBER, string(_T("6E")));
gkey.AddToken(0, '0', CHARACTER, string(_T("EOD")));
gkey.AddToken(0, '1', NUMBER, string(_T("1F5")));
gkey.AddToken(0, 'v', NUMBER, string(_T("1")));
gkey.AddToken(0, 's', NUMBER, string(_T("15")));
gkey.AddToken(0, 'r', NUMBER, string(_T("0")));
gkey.UseBase10(false);
gkey.UseBytes(true);
gkey.ChecksumAlgorithm(Type2);
gkey.CreateKey();
finalkey = gkey.GetLicenseKey();

Points of Interest

One point as to me said, first readers of this article is really exists – why above example is hanging, when I compile and run it ? The answer also really exists – it's with mistake by name of Apple's double fail goto – so, way of goto is to repair it, that's code will work on you handmade version.

I've done it, as I myself thinking without ideal – so shortly, added few classes, few methods, few fields, some fastcall methods for harding disassembly and antidebuging breakpoints. Now I hope, that no one hacker in the world (source not provided) will hack this code – and I'm glad to present real working, but still battle prototype of license key registration-disassembly program.

For readers, that to them won't stay doubt about source, from (by secret – password to this program is) 91 methods supplied to article – something really could.

History

This is port to C++ original article License Key Generation by Donsw realised on C#, so detailed explanation of algorithms and library files with documentation possible find in it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer LLC "AMS"
Russian Federation Russian Federation
In 1991 year has received senior secondary education and entered in Moscow Economic-statistical Institute, by faculty of Supply mathematics, has studied to 2-nd course with high progress, and left it by own will.

With 1994-1996 years - serviced in army (navy fleet, now sailor of a stock).

Since 1999 year has begun my labour career, with job of computer operator, in department of computer maintenance developing learn-methodical documentation.

Single, on religion - atheist.

Comments and Discussions

 
SuggestionSource Code Link Not Working..... Pin
Gary Noble7-Mar-14 6:04
Gary Noble7-Mar-14 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.