| Crates.io | machineid-crystal |
| lib.rs | machineid-crystal |
| version | 1.2.6 |
| created_at | 2025-02-20 03:44:29.394363+00 |
| updated_at | 2025-03-04 11:35:48.319504+00 |
| description | Get an encrypted unique MachineID/HWID/UUID. Inspired by .Net DeviceId. |
| homepage | |
| repository | https://github.com/Crystal-Server/machineid-crystal.git |
| max_upload_size | |
| id | 1562226 |
| size | 58,016 |
This crate is a fork of the original crate to provide some fixes and maintenance. This Rust package is inspired by DeviceId, a .Net package to build a unique Machine ID.
First add this to your Cargo.toml file
[dependencies]
machineid-crystal = "1.2.5"
Then, you need to define the builder variable with the hashing type you want.
For example, SHA256
use machineid_crystal::{IdBuilder, Encryption};
// There are 3 different hashing types: MD5, SHA1 and SHA256.
let mut builder = IdBuilder::new(Encryption::SHA256);
After that, you just need to add the components you want the id to have.
The available components are:
System UUID: Unique identifier of your machine
CPU Cores: Number of physical cores from your computer
OS Name: Operative System name, i.e., linux/windows
Username: The username currently being used
Machine Name: The name of the machine
CPU ID: The serial number of the processor
Drive Serial : The serial number of the disk storing the OS.
For example, i will add the System UUID and CPU Cores
use machineid_crystal::HWIDComponent;
builder.add_component(HWIDComponent::SystemID).add_component(HWIDComponent::CPUCores);
Once you are ready, you just need to build the id with your key
let hwid = builder.build("mykey").unwrap();
Feel free to report any bug you find! ;)