10 stable releases

2.0.0 Mar 24, 2024
1.2.0 Mar 21, 2024
1.1.2 Feb 7, 2024
1.1.0 Dec 8, 2023
1.0.1 Nov 29, 2023

#119 in Operating systems

Download history 8/week @ 2024-02-03 24/week @ 2024-02-17 15/week @ 2024-02-24 276/week @ 2024-03-02 71/week @ 2024-03-09 170/week @ 2024-03-16 172/week @ 2024-03-23 30/week @ 2024-03-30 7/week @ 2024-04-06 35/week @ 2024-04-13 68/week @ 2024-04-20

141 downloads per month
Used in public-ip-address

MIT/Apache

15KB
227 lines

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

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

v2.0.0 - March 24, 2024

  • Returned to_lowercase() for Windows MID result, which was mistakenly removed in v1.1.3. This will change the current Windows device hashes! If necessary, use version 2.0.0 for new projects only, or ask users to re-bind the license for new hashes in the current project.
  • Added mid::data function that returns data structure: key, result, hash.
  • mid::print outputs data to the console only in debug mode, it will not be included in the release build of the project.
  • Linux uses 3 sources to get machine-id.
  • The secret key for hashing cannot be empty.
  • Complete code refactoring has been performed.

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.

Linux

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

Unfortunately, this parameter is subject to change, and a reliable solution for Linux has not been found yet.

Windows

PowerShell - expandable automation tool. Parameters used:

  • powershell -command "Get-WmiObject Win32_ComputerSystemProduct": Returns the unique product identifier (UUID) 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.

  • powershell -command "Get-WmiObject Win32_BIOS": Returns the computer's BIOS serial number. It usually remains constant and does not change.

  • powershell -command "Get-WmiObject Win32_BaseBoard": Returns the serial number of the computer's baseboard. It usually remains constant and does not change.

  • powershell -command "Get-WmiObject Win32_Processor": Returns the computer's processor identifier. It should remain unchanged, except in cases of processor replacement.

Installation

Add the dependency to Cargo.toml

[dependencies]
mid = "2.0.0"

Or install using Cargo CLI

cargo add mid

How to Use

Get machine ID hash

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

Get MID key/result/hash data

let mid_data = mid::data("mySecretKey").unwrap();

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

mid::print("mySecretKey");
  • MID key - The secret key for hashing
  • MID result - Array of OS parameters
  • MID hash - SHA-256 hash from result

Subscribe to my X

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

References

Dependencies

~41KB