2 unstable releases

0.2.0 Aug 23, 2020
0.1.0 Oct 2, 2018

#2 in #uid

Download history 2734/week @ 2022-06-09 3119/week @ 2022-06-16 4142/week @ 2022-06-23 2936/week @ 2022-06-30 3945/week @ 2022-07-07 3245/week @ 2022-07-14 4277/week @ 2022-07-21 3706/week @ 2022-07-28 4554/week @ 2022-08-04 3864/week @ 2022-08-11 3741/week @ 2022-08-18 3642/week @ 2022-08-25 2717/week @ 2022-09-01 3058/week @ 2022-09-08 2668/week @ 2022-09-15 2334/week @ 2022-09-22

11,407 downloads per month
Used in 4 crates

MIT license

8KB
89 lines

machine-uid

Get os native machine id without root permission.

machine-uid on Travis CI machine-uid on crates.io machine-uid on docs.rs

About machine id

In Linux, machine id is a single newline-terminated, hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a 16-byte/128-bit value. This ID may not be all zeros. This ID uniquely identifies the host. It should be considered "confidential", and must not be exposed in untrusted environments. And do note that the machine id can be re-generated by root.

Usage

extern crate machine_uid;

fn main() {
    let id: String = machine_uid::get().unwrap();
    println!("{}", id);
}

How it works

It get machine id from following source:

Linux or who use systemd:

cat /var/lib/dbus/machine-id # or /etc/machine-id

BSD:

cat /etc/hostid # or kenv -q smbios.system.uuid

OSX:

ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID

Windows:

(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography).MachineGuid

Supported Platform

I have tested in following platform:

  • Debian 8
  • OS X 10.6
  • FeeBSD 10.4
  • Fedora 28
  • Windows 10

License

MIT License Copyright (c) 2018, Hanaasagi

Dependencies

~42KB