Coder Social home page Coder Social logo

xaf / machine-uid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hanaasagi/machine-uid

0.0 1.0 0.0 29 KB

Get machine id without root permission

Home Page: https://crates.io/crates/machine-uid

License: MIT License

Shell 19.76% C++ 10.46% Rust 69.78%

machine-uid's Introduction

machine-uid

Get os native machine id without root permission.

machine-uid on GitHub Action machine-uid on crates.io total downloads 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.

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

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:

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

Changelog

v0.5.0

  • Fix cross-compilation issue #7

v0.4.0

  • Fix x86 program run on x64 #4

v0.3.0

  • Upgrade winreg to 0.11

v0.2.0

  • Added support for Windows

License

MIT License Copyright (c) 2018, Hanaasagi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.