# LicenseSystemSDKCPP **Repository Path**: crossf1re/license-system-sdkcpp ## Basic Information - **Project Name**: LicenseSystemSDKCPP - **Description**: 软件激活管理系统 C++ 开发者SDK - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-25 - **Last Updated**: 2025-03-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Rain激活系统 C++ SDK 这是一套与Rain激活系统配套的SDK,对接此SDK可**保护你软件或者添加某种授权机制** ## 1. 前往账户界面复制你的公钥 公钥用于解码本地存储的凭证,开发者的公钥是独立的 前往平台 `我的账号` 并找到密钥 ![](resource/public_key.png) 复制此公钥并保存在源代码中,一个建议是单独新建一个`key.h`文件并放入其中 ## 2. 配置产品API ID 你需要为你的每一个APP配置好你的产品API ID,各个产品下的密钥是不通用的,一个产品只能激活属于它自己的产品,这保证产品之间的独立性和安全性 ![](resource/api_id.png) 我们稍后会用到产品的API ID ## 3. 在代码中使用SDK ### 代码实战 以下是一个简单的激活例子 ```c++ #include #include #include "key.h" //你的公钥 int main() { using namespace LibLicense; using namespace std; CLicenseChecker license_checker("7006a289c3702264357ba47a4ac6f293", "license.bin"); license_checker.setDecryptionKey(pubKey); try { CLicenseInfo info = license_checker.processLicenseCheck(); //一旦返回则成功 //此处可添加跳转逻辑 } catch (const LicenseException &e) { if (e.getErrorType() == LicenseError::KeyNotFound) bool ok = false; while (!ok) { cout << "Please type key to use this program: "; string license_key; cin >> license_key; try { license_checker.activateLicense(license_key); cout << "Activation success!" << endl; ok = true; } catch (const LicenseException &g) { cout << g.what << endl; } } } else { cout << e.what << endl; } } return 0; } ``` CLicenseChecker 是我们用于检查密钥用到最主要的类,其中包含方法: ### 3.1 构造函数 - productAPIKey - 你的产品API ID,用于分辨不同的APP - licenseFilePath - 产品的凭证文件路径,应该将凭证保存在哪里 ### 3.2 setDecryptionKey - key - 你的公钥,用于解密凭证 ### 3.3 processLicenseCheck 用途: 从凭证文件路径获取凭证并检查合法性 返回值: 返回一个`CLicenseInfo`对象,如果失败,则抛出异常 ### 3.4 activateLicense - license_key - 软件激活密钥 用途: 收集计算机信息并向上流服务器发送激活请求以获取凭证 返回值: 返回一个`CLicenseInfo`对象,如果失败或网络错误,则抛出异常 ## 依赖 1. cryptopp 2. nlohmann json 3. httplib ## Todo 1. Async support 2. Virtual machine protection