# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Build ```bash cmake -B build -G "Visual Studio 17 2022" -A x64 # Windows (MSVC) cmake -B build # Linux / macOS cmake --build build --config Release ``` No external dependencies — built-in SHA-256, RC4, Base64, CRC32, and a minimal JSON parser. ## Commands | Command | Description | |---|---| | `regInfo machinecode` (or `mc`) | Print a 256-bit machine ID as 64 hex chars (SHA-256 of CPU + system disk) | | `regInfo generate -f [outfile]` (or `gen`) | Create an encrypted license file from a JSON file | | `regInfo generate [outfile]` | Create a license from an inline JSON string | | `regInfo read ` (or `rd`) | Decrypt and display all license fields as pretty-printed JSON | | `regInfo -f -` | Read and output a single field. Repeat for multiple fields. | | `regInfo -f -verify` | Validate license, outputting an error code (see below) | Field flags: `-name`, `-machinecode`, `-phone`, `-unit`, `-authdatetime`, `-over`, `-update` Verify error codes: `0` = valid, `10001` = file invalid, `10002` = expired, `10004` = machine code mismatch **Important:** `generateLicenseFile()` in [src/license.cpp](src/license.cpp#L26) currently returns `false` immediately — generation is stubbed out. Reading/verification work normally. ## License file format Files (`*.xlts`) use: `base64(MAGIC[4] + CRC32[4] + RC4_encrypted(JSON))` - MAGIC: `RLIC` (4 bytes) - CRC32: big-endian checksum of the RC4-encrypted payload (4 bytes) - RC4 key: hardcoded in [src/license.cpp](src/license.cpp#L15-L20) - JSON payload fields: `name`, `machinecode`, `phone`, `unit`, `authdatetime`, `overdatetime`, `updatedatetime` - Verification is a simple string comparison of `machinecode` against `getMachineCode()` — intentionally not cryptographically secure ## Architecture ``` src/ main.cpp — CLI dispatch (machinecode / generate / read) machine_code.cpp — Platform-specific CPU + disk identification license.cpp — License file encryption/decryption + validation crypto.cpp — RC4 stream cipher, Base64, CRC32 json_utils.cpp — Minimal JSON parser (flat objects, string values only) include/ machine_code.h — getMachineCode() → std::string license.h — LicenseInfo struct, generateLicenseFile(), readLicenseFile() crypto.h — rc4Crypt(), base64Encode/Decode(), crc32() json_utils.h — JsonObject with parse/dump for string-only key/value pairs ``` Platform-specific `#ifdef` sections in `machine_code.cpp` cover Windows (`CPUID`, `GetVolumeInformation`, `IOCTL_STORAGE_GET_DEVICE_NUMBER`), Linux (`/proc/cpuinfo`, `statfs`, `sched_setaffinity` for deterministic CPUID), and macOS (`sysctl`, `statfs`). ## GUI ``` gui/license_gui.py ``` A tkinter-based GUI for generating license files. Fields: name, phone, unit, machinecode (auto-filled), authdatetime (auto today), overdatetime/updatedatetime (date pickers). Filename pattern: `license__.xlts`. Requires Python 3 with tkinter (built-in on most systems).