License Key Generation






4.61/5 (11 votes)
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:
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.