C++ SDK
The reference C++17 SDK lives in sdk/cpp. Use the REST examples for JavaScript, Python or C#. No package registry install is required for those examples.
Get the SDK and runnable examples on GitHub.
Requirements
- C++17 compiler, CMake 3.16+, OpenSSL development libraries.
- cpp-httplib header at
sdk/cpp/deps/httplib.h. - nlohmann/json header at
sdk/cpp/deps/nlohmann/json.hpp. - Monocypher is included under
sdk/cpp/third_party.
Installation
cd sdk/cpp
# Place httplib.h and nlohmann/json.hpp in deps/ first.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseWindows: use a Visual Studio developer shell and configure with -A x64. Ensure CMake can find your OpenSSL installation.
Activate and validate
#include <memory>
#include <authix/authix.h>
int main() {
authix::Client client("https://authix.top", "your-product-slug");
client.setAppVersion("1.0.0");
const std::string key = "YOUR-LICENSE-KEY";
auto activation = client.activate(key);
if (activation.failed()) return 1;
auto validation = client.validate(key);
if (validation.failed() || !validation.value().valid) return 1;
// Run protected functionality only while validation remains valid.
auto released = client.deactivate(key);
return released.ok() ? 0 : 1;
}Heartbeat and status changes
client.onStatusChange([](authix::LicenseStatus status) {
if (status != authix::LicenseStatus::Active) {
// Stop protected functionality.
}
});
auto heartbeat = client.heartbeat(key);
if (heartbeat.failed() || !heartbeat.value().valid) {
// Stop protected functionality; retry according to your policy.
}Feature entitlements
auto result = client.getEntitlements(key);
if (result.ok()) {
for (const auto& feature : result.value()) {
// Interpret feature.value according to feature.valueType.
}
}File grants and downloads
auto files = client.listFiles(key);
if (files.ok() && !files.value().empty()) {
const auto& file = files.value().front();
if (!file.downloadToken.empty()) {
auto download = client.downloadFile(key, file.id, "./downloads", file.downloadToken);
if (download.failed()) {
// Request a fresh grant before retrying a consumed/expired token.
}
}
}The sample C++ client uses the legacy catalog-file flow. For session-bound VZENC2 delivery, follow the loader delivery guide and implement session handling and decryption in your loader. Do not treat the sample client as a complete encrypted updater.
Offline licenses
auto offline = client.getOfflineLicense(key);
if (offline.ok()) {
// Verify payload + signature with your trusted embedded Ed25519 key.
// Check HWID and expiry before permitting offline access.
}The Client returns the offline blob; your application must verify and enforce it.
Device identity and errors
The current Windows fingerprint combines machine SID, CPUID and a persisted LocalAppData device token, then hashes them with SHA-256. setHwid(hash) overrides it. Weak or empty hashes never create seats. Handle errors using result.error().code; avoid logging keys, session secrets, or binary contents.
Complete console example
/**
* Authix SDK - Example Application
*
* Demonstrates:
* 1. Activating a license key
* 2. Validating periodically
* 3. Checking entitlements
* 4. Deactivating on exit
*/
#include <authix/authix.h>
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include <atomic>
// Your Authix server URL
static const char* API_URL = "https://licenses.yourdomain.com";
std::atomic<bool> g_running{true};
void validationLoop(authix::Client& client, const std::string& key) {
while (g_running) {
std::this_thread::sleep_for(std::chrono::minutes(5));
if (!g_running) break;
auto result = client.heartbeat(key);
if (result.failed()) {
std::cerr << "[Authix] Heartbeat failed: " << result.error().message << "\n";
// In a real app, you might lock out the user after repeated failures
}
}
}
int main() {
std::cout << "=== Authix SDK Example ===\n\n";
// 1. Create the SDK client
authix::Client client(API_URL);
client.setAppVersion("1.0.0");
client.setMachineLabel("dev-workstation");
// Optional: set a callback for status changes
client.onStatusChange([](authix::LicenseStatus status) {
switch (status) {
case authix::LicenseStatus::Active:
std::cout << "[License] Status: ACTIVE\n";
break;
case authix::LicenseStatus::Suspended:
std::cerr << "[License] WARNING: License suspended!\n";
break;
case authix::LicenseStatus::Revoked:
std::cerr << "[License] CRITICAL: License revoked!\n";
break;
case authix::LicenseStatus::Expired:
std::cerr << "[License] License expired.\n";
break;
default:
break;
}
});
// 2. Show the HWID
std::string hwid = authix::hwid::generate();
std::cout << "Machine HWID: " << hwid << "\n\n";
// 3. Get license key from user
std::string licenseKey;
std::cout << "Enter license key: ";
std::getline(std::cin, licenseKey);
if (licenseKey.empty()) {
std::cerr << "No key provided.\n";
return 1;
}
// 4. Activate
std::cout << "\nActivating...\n";
auto activateResult = client.activate(licenseKey);
if (activateResult.failed()) {
std::cerr << "Activation failed: " << activateResult.error().message << "\n";
return 1;
}
auto& activation = activateResult.value();
std::cout << "Activation successful!\n";
std::cout << " Activation ID: " << activation.activationId << "\n";
std::cout << " Expires: " << (activation.license.expiresAt.empty() ? "Never" : activation.license.expiresAt) << "\n";
std::cout << " Activations: " << activation.license.activationCount
<< "/" << activation.license.maxActivations << "\n\n";
// 5. Check entitlements
auto entResult = client.getEntitlements(licenseKey);
if (entResult.ok()) {
std::cout << "Entitlements:\n";
for (const auto& e : entResult.value()) {
std::cout << " " << e.code << " = " << e.value << " (" << e.valueType << ")\n";
}
std::cout << "\n";
}
// 6. Start background validation
std::thread validationThread(validationLoop, std::ref(client), licenseKey);
// 7. Main application loop
std::cout << "Application running. Type 'quit' to exit.\n";
std::string line;
while (std::getline(std::cin, line)) {
if (line == "quit" || line == "exit") break;
if (line == "validate") {
auto v = client.validate(licenseKey);
if (v.ok()) {
std::cout << "Valid: " << (v.value().valid ? "yes" : "NO") << "\n";
} else {
std::cout << "Validation error: " << v.error().message << "\n";
}
}
}
// 8. Cleanup: deactivate and stop
g_running = false;
std::cout << "\nDeactivating...\n";
auto deactResult = client.deactivate(licenseKey);
if (deactResult.ok()) {
std::cout << "Deactivated successfully.\n";
} else {
std::cerr << "Deactivation failed: " << deactResult.error().message << "\n";
}
if (validationThread.joinable()) {
validationThread.join();
}
return 0;
}