Overview
License C++ library offers a licensing feature for C++ applications. The library provides functions for generating a token (based on username and MAC address of the ethernet adaptor or user provided key), 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
namespace cr
{
namespace utils
{
/// License class.
class License
{
public:
/// Get License class version.
static std::string getVersion();
/// Create token based on user name and key (if key is empty, MAC address is used).
std::string getToken(std::string userName, std::string key = "");
/// Extract information from a token.
bool getTokenInfo(std::string token, std::string &userName,
std::string &key);
/// Initialize a license.
bool getLicense(std::string token, int days, std::string &license);
/// Extract info from a license.
bool getLicenseInfo(std::string license, std::string &userName,
std::string &key, int &daysLeft);
/// Check status of license. If key is empty, MAC address is used.
bool checkLicense(std::string license, std::string userName, std::string key = "");
};
}
}
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;

