Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanaasagi/machine-uid
Get machine id without root permission
https://github.com/hanaasagi/machine-uid
cross-platform hostid machine-id uid
Last synced: 2 days ago
JSON representation
Get machine id without root permission
- Host: GitHub
- URL: https://github.com/hanaasagi/machine-uid
- Owner: Hanaasagi
- License: mit
- Created: 2018-09-30T16:36:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T10:10:06.000Z (2 months ago)
- Last Synced: 2024-12-27T11:54:30.946Z (9 days ago)
- Topics: cross-platform, hostid, machine-id, uid
- Language: Rust
- Homepage: https://crates.io/crates/machine-uid
- Size: 33.2 KB
- Stars: 28
- Watchers: 4
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# machine-uid
Get os native machine id without root permission.
[![machine-uid on GitHub Action][action-image]][action]
[![machine-uid on crates.io][cratesio-image]][cratesio]
[![total downloads][downloads-image]][cratesio]
[![machine-uid on docs.rs][docsrs-image]][docsrs][action-image]: https://github.com/Hanaasagi/machine-uid/actions/workflows/rust.yml/badge.svg
[action]: https://github.com/Hanaasagi/machine-uid/actions/workflows/rust.yml
[cratesio-image]: https://img.shields.io/crates/v/machine-uid.svg
[downloads-image]: https://img.shields.io/crates/d/machine-uid
[cratesio]: https://crates.io/crates/machine-uid
[docsrs-image]: https://docs.rs/machine-uid/badge.svg
[docsrs]: https://docs.rs/machine-uid### 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.
**Please note that on \*nix platforms, this library does not require any dependencies,
but on Windows, it requires the `winreg` dependency. So if you only need to build the \*nix version,
you can use version 0.3.0.**### Usage
```Rust
use 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:
```Bash
cat /var/lib/dbus/machine-id # or /etc/machine-id
```BSD:
```Bash
cat /etc/hostid # or kenv -q smbios.system.uuid
```OSX:
```Bash
ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID
```Windows:
```powershell
(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography).MachineGuid
```illumos:
```Bash
gethostid(3C)
```### Supported Platform
I have tested in following platform:
- Debian 8
- OS X 10.6
- FreeBSD 10.4
- Fedora 28
- Windows 10
- OmniOS r151050### Changelog
#### v0.5.3
- Remove built in C dependency [#13](https://github.com/Hanaasagi/machine-uid/pull/13)
#### v0.5.2
- Add illumos support [#11](https://github.com/Hanaasagi/machine-uid/pull/11)
- Upgrade winreg to 0.52 [#12](https://github.com/Hanaasagi/machine-uid/pull/12)
- Upgrade bindgen to 0.69 [#12](https://github.com/Hanaasagi/machine-uid/pull/12)#### v0.5.1
- Upgrade winreg to 0.50 [#9](https://github.com/Hanaasagi/machine-uid/pull/9)
- Upgrade bindgen to 0.66 [#8](https://github.com/Hanaasagi/machine-uid/pull/8)#### v0.5.0
- Fix cross-compilation issue [#7](https://github.com/Hanaasagi/machine-uid/pull/7)
#### v0.4.0
- Fix x86 program run on x64 [#4](https://github.com/Hanaasagi/machine-uid/pull/4)
#### v0.3.0
- Upgrade winreg to 0.11
#### v0.2.0
- Added support for Windows
### License
[MIT License](https://github.com/Hanaasagi/machine-id/blob/master/LICENSE) Copyright (c) 2018, Hanaasagi