Skip to content
dorovedPublic

About

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

Topics

Resources

Stars

48 stars

Watchers

3 watching

Forks

Repository files navigation

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

Made with ❤️ for Tauri

README RU

Latest Change Log

v5.1.0 - November 6, 2026

  • Windows: Replaced PowerShell/WMI calls with direct SMBIOS table reading via smbios-lib (GetSystemFirmwareTable Win32 API) — no external shell processes are spawned, while preserving the same hardware ID format and hash.
  • Linux: Replaced shell commands (sh, hostnamectl, awk, cat) with direct file reading (/etc/machine-id, /var/lib/dbus/machine-id, /sys/class/dmi/id/product_uuid).
  • macOS: Added Golden Gate codename support for macOS 27 in mid::additional_data.
  • Updated dependencies.

Full Change Log

mid

Creating a Machine ID hash.

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

Supported Platforms

  • MacOS
  • Windows
  • Linux
  • iOS

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:

  • Model Number: This parameter represents the computer or device model number. It is used for uniquely identifying a specific model within the manufacturer's range.

  • Serial Number: This parameter is the unique serial number of the computer or device. It is used to identify a specific unit within a particular model.

  • Hardware UUID: This parameter represents the hardware UUID of the computer or device. It serves to provide unique identification of a specific unit across different systems and environments.

  • Provisioning UDID: This parameter represents the device's unique device identifier (UDID), which can be used in the provisioning process or device setup, usually in a corporate or managed environment.

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:

  • Platform ID: The unique identifier of the platform to which the Secure Element belongs.
  • SEID: The unique identifier of the Secure Element. Created during the NFC chip firmware at the manufacturer's factory.

Windows

System information is read directly from SMBIOS tables via the GetSystemFirmwareTable Win32 API — no shell processes are spawned. Parameters used:

  • System UUID (SMBIOS Type 1): The unique product identifier of the computer. Usually associated with the computer's motherboard. In rare cases, it may change after replacing or reinstalling the motherboard or after changing the device's BIOS/UEFI.

  • BIOS Serial Number (SMBIOS Type 1): The computer's BIOS serial number. It usually remains constant and does not change.

  • Baseboard Serial Number (SMBIOS Type 2): The serial number of the computer's baseboard. It usually remains constant and does not change.

  • Processor ID (SMBIOS Type 4): The computer's processor identifier. It should remain unchanged, except in cases of processor replacement.

Linux

System information is read directly from filesystem — no shell processes are spawned. Sources used:

  • /etc/machine-id: A machine identifier (ID) that is used to uniquely identify a computer on Linux systems.

  • /var/lib/dbus/machine-id: An alternative location for the machine identifier, used on some distributions.

  • /sys/class/dmi/id/product_uuid: The system product UUID from DMI/SMBIOS tables (requires root access).

Unfortunately these parameters are subject to user modification and no reliable solution for Linux has been found yet.

iOS

  • Keychain: The identifier is generated randomly (SHA-256 of Nanoid + Timestamp) and stored in the Keychain. It persists across app reinstallations on real devices.

iOS Instructions

Installation

Add the dependency to Cargo.toml

[dependencies]
mid = "5.1.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", "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", "SEID"]
MID.print[hash]: 3f9af06fd78d3390ef35e059623f58af03b7f6ca91690f5af031b774fd541977
  • MID key - The secret key for hashing
  • MID result - Array of OS parameters
  • MID hash - SHA-256 hash from result

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", model_name: "MacBook Pro", os_name: "Sequoia", os_version: "15.7", os_full: "Sequoia 15.7", chip: "Apple M1 Pro", chip_short: "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

About

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

Topics

Resources

Stars

48 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages