doroved / mid

Creating a Machine ID hash for MacOS/Windows/Linux
https://crates.io/crates/mid
27 stars 1 forks source link
auth authentication deviceid hardwareid hostid hwid library machine-id machine-identity machineid rust uuid

Crates.io Version Crates.io Total Downloads docs.rs

Made with ❤️ for Tauri

README RU

mid

Creating a Machine ID hash for MacOS/Windows/Linux.

Utilizes the most static system parameters possible to generate reliable device hashes for licensing your software.

Change Log

v3.0.0 - September 18, 2024

[!IMPORTANT] Platform ID has been removed from the mac device hash dataset because after upgrading from macos 14.x to 15.0, it changed, causing the device hash to change. Use this version only for new projects or update the device hashes of your current users.

v2.1.0 - June 30, 2024

v2.0.0 - March 24, 2024


List of parameters that are used on each platform.

MacOS

system_profiler SPHardwareDataType

The command returns information about the computer's hardware characteristics. Parameters used:

system_profiler SPSecureElementDataType

The command returns information about the Secure Element. This element is used to store encrypted data, such as information about payment cards and other confidential data. Parameters used:

Windows

PowerShell - expandable automation tool. Parameters used:

Linux

Unfortunately this parameter is subject to user modification and no reliable solution for Linux has been found yet.

Installation

Add the dependency to Cargo.toml

[dependencies]
mid = "3.0.0"

Or install using Cargo CLI

cargo add mid

How to Use

Get machine ID hash

let machine_id = mid::get("mySecretKey").unwrap();
Example: 3f9af06fd78d3390ef35e059623f58af03b7f6ca91690f5af031b774fd541977

Get MID key/result/hash data

let mid_data = mid::data("mySecretKey").unwrap();
MacOS example: MidData { key: "mySecretKey", result: ["ModelNumber", "SerialNumber", "HardwareUUID", "ProvisioningUDID", "SEID"], hash: "3f9af06fd78d3390ef35e059623f58af03b7f6ca91690f5af031b774fd541977" }

Output the MID key/result/hash to the console in debug_assertions mode

mid::print("mySecretKey");
MacOS example:
MID.print[key]: mySecretKey
MID.print[result]: ["ModelNumber", "SerialNumber", "HardwareUUID", "ProvisioningUDID", "SEID"]
MID.print[hash]: 3f9af06fd78d3390ef35e059623f58af03b7f6ca91690f5af031b774fd541977

Get additional device data

This data does not contribute to the device hash. Currently available for MacOS only.

let additional_data = mid::additional_data().unwrap();
println!("{:?}", additional_data);
AdditionalData { username: "doroved", hostname: "MacBook-Pro--doroved.local", os_name: "Sonoma", os_version: "14.5", os_full: "Sonoma 14.5", chip: "Apple M1 Pro", memsize: 16, cpu_core_count: 8, languages: ["ru-RU", "bg-RU", "en-RU"] }

Subscribe to my X

Here I will share my developments and projects https://x.com/doroved

References