machineid-rs
Build a unique, encrypted machine ID (HWID) in Rust from customizable hardware and OS components.
Repository Health
Technical Analysis
machineid-rs is a Rust library for generating a unique, encrypted machine identifier (also called an HWID or device ID) from the characteristics of the host system. Inspired by the .NET DeviceId package, it lets you compose an ID from components such as the system UUID, CPU ID, CPU core count, OS name, username, machine name, and drive serial number, then hashes the result with your chosen algorithm.
It supports MD5, SHA1, and SHA256 hashing via HMAC and works on Windows, Linux, and macOS without requiring administrator privileges. The builder-style API makes it straightforward to pick exactly which hardware and environment signals contribute to the fingerprint, which is useful for licensing, device binding, and anti-abuse scenarios.
What You Get
- A builder API to compose a machine ID from selectable hardware/OS components
- Three hash options (MD5, SHA1, SHA256) applied via HMAC with your key
- Components including system UUID, CPU ID, CPU cores, OS name, username, machine name, drive serial
- Cross-platform support for Windows, Linux, and macOS with no admin rights needed
- Hex-encoded, deterministic output suitable for licensing and device binding
Common Use Cases
- Binding a software license to a specific machine
- Generating a stable device fingerprint for authentication or fraud prevention
- Identifying returning devices without storing personal data
- Creating a per-machine key or seed for local encryption
Under The Hood
Architecture - lib.rs defines the IdBuilder and Encryption enum plus the component list; per-OS modules (windows.rs, linux.rs, macos.rs) implement the actual collection of each hardware/system value, selected at compile time via cfg. utils.rs and errors.rs provide helpers and error types. When you build the ID, the selected component strings are concatenated and passed through an HMAC of the chosen hash function, then hex-encoded.
Tech Stack - Rust (edition 2018). Uses sysinfo and whoami to read system data, uuid for UUIDs, hmac with md-5/sha-1/sha2 for hashing, hex for encoding, and serde for data handling. On Windows it pulls in winreg and wmi; on Unix it uses serde_json. Licensed MIT OR Apache-2.0.
Code Quality - A modest project (70 commits, 8 contributors) with a clear per-platform module split. Component collection inherently depends on OS-specific sources, which the cfg-gated modules isolate cleanly. The repository has been inactive since 2024, so it is stable but not actively evolving; consumers should validate behavior on newer OS versions.
API Design - The builder pattern is intuitive: choose an encryption type, add the components you care about, and build with a key. Naming maps directly onto familiar concepts (Encryption::SHA256, add_component), and the README examples make first use quick. Because outputs depend on hardware that can change (e.g. a swapped drive), the API’s flexibility in component selection is an important design affordance.