项目结构
regInfo/ ├── CMakeLists.txt # CMake 构建(无外部依赖) ├── CLAUDE.md ├── include/ │ ├── machine_code.h # 获取机器码接口 │ ├── license.h # 生成/读取注册文件接口 │ ├── crypto.h # RC4/Base64/CRC32 │ └── json_utils.h # 内置轻量 JSON 解析器 ├── src/ │ ├── main.cpp # CLI 入口 │ ├── machine_code.cpp # CPU+硬盘 → 32位机器码 │ ├── license.cpp # 注册文件加密/解密 │ ├── crypto.cpp # 加密算法实现 │ └── json_utils.cpp # JSON 解析/序列化 └── build/Release/regInfo.exe # 编译产物 三个接口 命令 功能 regInfo machinecode 获取 8 位十六进制机器码(基于 CPU + 系统硬盘) regInfo generate -f [输出文件] 生成加密注册文件 license.xlts regInfo read <注册文件> 解密并显示注册信息 已验证的功能 机器码:BA8BAE64(每次调用一致,基于 CPUID + 硬盘序列号) 生成注册文件:JSON → RC4加密 → Base64 → license.xlts 读取注册文件:license.xlts → Base64解码 → RC4解密 → 还原JSON 构建命令
cmake -B build cmake --build build --config Release 跨平台支持 Windows(已验证)/ Linux / macOS,无任何外部依赖。
现在代码在 Windows x64(已验证编译)、Linux x86/ARM、macOS Intel/Apple Silicon 上均可直接 cmake --build 编译运行
# 编译
g++ -std=c++17 -I include -o build/regInfo \
src/main.cpp \
src/machine_code.cpp \
src/license.cpp \
src/crypto.cpp \
src/json_utils.cpp
# 测试
build/regInfo machinecode # 获取机器码
build/regInfo generate -f <json文件> [输出文件] # 生成 license
build/regInfo read <license文件> # 读取 license
build/regInfo -f <license文件> -verify # 验证 license
build/regInfo -f <license文件> -<字段名> # 读取指定字段
编译环境:g++ ≥ 7(C++17),无外部依赖。已验证 g++ 11.4.0 (Ubuntu 22.04)。
调用说明: regInfo.exe machinecode Get this machine's unique code
regInfo.exe read Read and display all license info regInfo.exe -f - Show specific field(s) regInfo.exe -f -verify Verify license validity
Fields: -name, -machinecode, -phone, -unit, -authdatetime, -over, -update
注册文件校验错误Verify error codes: 0 valid 注册文件有效 10001 license file invalid 文件无效 10002 license expired (overdatetime) 过期 10004 machine code mismatch 机器码不匹配 rwxrwxr-x 1 lc lc 95944 5月 31 23:32 regInfo
注册生成的json文件格式如下: {"name":"...", "machinecode":"...", "phone":"...", "unit":"...", "authdatetime":"...", "overdatetime":"...", "updatedatetime":"..."}
| 工具 | 版本 | 说明 |
|---|---|---|
| Python | ≥ 3.9 | 已验证 3.11.9 |
| PyInstaller | ≥ 6.0 | pip install pyinstaller |
| regInfo.exe | 已编译 | 需先完成 C++ 编译,生成 build/Release/regInfo.exe |
# 1. 先编译 C++ 项目(如未编译)
cmake -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release
# 2. 安装 PyInstaller(如未安装)
pip install pyinstaller
# 3. 打包 GUI(单文件,内嵌 regInfo.exe)
python -m PyInstaller \
--noconfirm \
--onefile \
--windowed \
--name "LicenseGUI" \
--add-binary "K:/work/regInfo/build/Release/regInfo.exe;." \
--distpath K:/work/regInfo/gui/dist \
--workpath K:/work/regInfo/gui/build_tmp \
--specpath K:/work/regInfo/gui/build_tmp \
K:/work/regInfo/gui/license_gui.py
gui/dist/LicenseGUI.exe # 独立可执行文件(约 11MB),内嵌 regInfo.exe
运行方式:双击 LicenseGUI.exe 即可启动注册文件生成器 GUI 界面,无需额外安装 Python 或 regInfo。