Overview
License C++ library offers a licensing feature for C++ applications. The library provides functions for generating a token (base on username and MAC address of the computer), creating a license based on it, and validating the license with control of its validity time. AES256 encryption method is implemented. To embed licensing in a C++ application, generate a token, then based on the token and the required number of days generate a license string (key). License checking in the application is performed by a single library function. The library doesn’t have any third-party dependencies and provide simple interface. It uses C++17 standard and compatible with Linux and Windows.
Documentation
Documentation: GOT TO DOCUMENTATION
Simple interface
#include <iostream>
#include "License.h"
int main(void)
{
std::cout << "LicenseGenerator v" <<
cr::utils::License::getVersion() << std::endl;
// Set user name to generate license.
std::string userName = "";
std::cout << "Enter the UserName to generate license: ";
std::cin >> userName;
// Set license duration.
int days = 0;
std::cout << "Enter license duration [days]: ";
std::cin >> days;
// Create License object and generate token for license.
cr::utils::License lic;
std::string token = lic.getToken(userName);
std::cout << "Token for " << userName << ": " <<
token << std::endl;
// Generate license.
std::string license = "";
if (!lic.getLicense(token, days, license))
{
std::cout << "Invalid token for " <<
userName << " !" << std::endl;
return -1;
}
// Check license.
if (!lic.checkLicense(license, userName))
{
std::cout << "Invalid license for " <<
userName << " !" << std::endl;
return -1;
}
// Show license.
std::cout << "License for " << userName <<
"[" << days << " days]: " << license << std::endl;
// Wait user input.
std::cin.get();
std::cin.get();
return 1;
}
Token string generation
std::string userName = "AnyUserName"; // Set by user.
cr::utils::License lic;
std::string token = lic.getToken(userName);
License string generation based on token
std::string license = ""; // Variable to store license string.
std::string token =
"0255D7EE2DFCFF80..."; // Example.
int days = 20; // License for 20 days, example.
if (!lic.getLicense(token, days, license))
{
std::cout << "Invalid token for " <<
userName << " !" << std::endl;
return -1;
}
License validation
std::string license =
"EE8C15F833832FF0BD..."; // Example.
std::string userName = "AnyUserName";
cr::utils::License lic;
if (!lic.checkLicense(license, userName))
{
std::cout << "Invalid license for " <<
userName << " !" << std::endl;
return -1;
}
std::cout << "License valid!" << std::endl;