Click here to Skip to main content
13,044,766 members (43,734 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 7 Mar 2014

License Key Generation

, 7 Mar 2014
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "License Key Generation"


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.


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.


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.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")));
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.


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.


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


About the Author

Software Developer LLC "AMS"
Russian Federation Russian Federation
No Biography provided

You may also be interested in...

Comments and Discussions

SuggestionSource Code Link Not Working..... Pin
Gary Noble7-Mar-14 6:04
memberGary 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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Mar 2014
Article Copyright 2014 by Adamanteus
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid