#uuid #unique-id #machine-id #hwid #hardware-id #sha-1 #machineuid

machineid-rs

Get an encrypted unique MachineID/HWID/UUID. Inspired by .Net DeviceId.

11 stable releases

1.2.4 Jul 25, 2023
1.2.3 Mar 10, 2023
1.2.2 Apr 25, 2022
1.2.1 Jan 9, 2022
1.1.0 Jul 30, 2021

#100 in Operating systems

Download history 14176/week @ 2024-03-14 16031/week @ 2024-03-21 14191/week @ 2024-03-28 13928/week @ 2024-04-04 12523/week @ 2024-04-11 13894/week @ 2024-04-18 13466/week @ 2024-04-25 14367/week @ 2024-05-02 13415/week @ 2024-05-09 13876/week @ 2024-05-16 2656/week @ 2024-05-23 2494/week @ 2024-05-30 2075/week @ 2024-06-06 2445/week @ 2024-06-13 3225/week @ 2024-06-20 1935/week @ 2024-06-27

10,036 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

24KB
531 lines

docs.rs docs

MachineID for Rust - Like .Net DeviceId

This Rust package is inspired by DeviceId, a .Net package to build a unique Machine ID.

Features

  • 3 Different types of hash (MD5, SHA1, SHA256)
  • Different components to make the ID
  • Support for Windows, Linux and MacOS
  • No Admin privileges are required

How to use

First add this to your Cargo.toml file

[dependencies]
machineid-rs = "1.2.4"

Then, you need to define the builder variable with the encryption type you want.

For example, SHA256

use machineid_rs::{IdBuilder, Encryption};

// There are 3 different encryption 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_rs::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();

Todo

  • Optimize the code

Feel free to report any bug you find! ;)

Dependencies

~2–29MB
~392K SLoC