#include #include #include #include #include #include"ANSLicense.h" //#include //#include int ANSFinalTemplate_ActivationExample() { std::string privateKey = "AQlSAiRTNtS7X20="; std::string URL = "http://localhost:3001/"; ANSCENTER::ANSLSHelper ansHelper(privateKey, URL); //std::string licenseTempatePath = "C:\\Projects\\ANLS\\LicenseTemplates\\ANSFinalTemplate.xml"; //bool loaded = ansHelper.LoadLicenseTemplate(licenseTempatePath); //std::cout << "Load license template from file:" << loaded << std::endl; // For fun to get HWID std::string hwid = ansHelper.GetCurrentHardwareId(); std::cout << "HWID:" << hwid << std::endl; std::string registrationName = "Alex Nguyen"; int productId = 1002; int enableFeature = 1; // Generate key based on productId std::string generatedKey = ansHelper.GenerateKey(productId, registrationName, enableFeature, false); std::cout << "Key:" << generatedKey << std::endl; bool isLicenseKeyValid = ansHelper.IsLicenseKeyValid(generatedKey, registrationName); std::cout << "Is license key valid:" << isLicenseKeyValid << std::endl; enableFeature = 0; bool result = ansHelper.CheckLicenseKey(generatedKey, registrationName, productId, enableFeature); std::cout << "validation result:" << result << std::endl; std::cout << "enable feature:" << enableFeature << std::endl; std::string activationKey = ""; int validationResult; validationResult = ansHelper.ValidateLicense(generatedKey, registrationName, activationKey); validationResult = ansHelper.ActivateLicense(generatedKey, registrationName, activationKey); std::cout << "validation result:" << validationResult << std::endl; std::cout << "activation Key:" << activationKey << std::endl; std::string trialKey = "7JBVC-PGKW4-BCLXF-ERTJQ-JKHBT-KVLHR"; std::string licenseData = ansHelper.GetLicenseData(trialKey); std::cout << "License Data" << licenseData << std::endl; std::string offlineActivationData = ""; int resultOL= ansHelper.GenerateOfflineActivationData(generatedKey, registrationName, offlineActivationData); std::cout << "Offline Activation Data" << offlineActivationData << std::endl; return 0; } int GenerateKey() { std::string privateKey = "AQlSAiRTNtS7X20="; std::string URL = "http://localhost:3001/"; ANSCENTER::ANSLSHelper ansHelper(privateKey, URL); std::string licenseTempatePath = "C:\\Projects\\ANLS\\LicenseTemplates\\ANSFinalTemplate.xml"; bool loaded = ansHelper.LoadLicenseTemplate(licenseTempatePath); std::cout << "Load license template from file:" << loaded << std::endl; // For fun to get HWID std::string hwid = ansHelper.GetCurrentHardwareId(); std::cout << "HWID:" << hwid << std::endl; std::string registrationName = "Thinh Nguyen"; int productId = 1002; int enableFeature = 12; int efea = 0; // Generate key based on productId std::string generatedKey = ansHelper.GenerateKey(productId, registrationName, enableFeature, false); std::cout << "Key:" << generatedKey << std::endl; bool valid= ansHelper.CheckLicenseKey(generatedKey,registrationName, productId, efea); std::cout << "License Valid:" << valid << " - feature:"<