Generate a unique hardware ID (HWID) for Windows, macOS, and Linux
Project description
HWIDGenerator
A Python utility that generates a unique hardware ID (HWID) for a device. It works on Windows, macOS and Linux! The HWID is a SHA-256 hash made from hardware-specific values so it's unique per machine.
How It Works
It collects some hardware info depending on your OS and hashes it all together with SHA-256. The result is always a 64-character hex string.
Windows
Uses PowerShell (Get-CimInstance) and the Python built-in winreg module to get:
| Source | Method | Value |
|---|---|---|
| CPU | PowerShell Win32_Processor |
ProcessorId |
| C: Drive (logical) | PowerShell Win32_LogicalDisk |
VolumeSerialNumber |
| Machine GUID | winreg (HKLM\SOFTWARE\Microsoft\Cryptography) |
MachineGuid |
No external packages required. No admin rights needed.
macOS
Uses ioreg and diskutil to get:
IOPlatformUUIDIOPlatformSerialNumber- Volume UUID
Linux
Uses /etc/machine-id and lsblk to get:
- Machine ID from
/etc/machine-id - Disk serial number
- Partition table UUID (PTUUID)
It automatically detects your primary disk so it works with both SATA (/dev/sda) and NVMe (/dev/nvme0n1) drives. No sudo needed!
Requirements
- Python 3.x
- No external packages needed on any platform — everything uses the Python standard library
Install development dependencies (testing, linting):
pip install -r requirements/requirements_dev.txt
Usage
from hwidgen import HWIDGenerator
hwid = HWIDGenerator.get_hwid()
print(hwid) # e.g. 884618235043ffce89d87862abf8882e...
Example Output
884618235043ffce89d87862abf8882eb5294517f107f0f980bec789258e8a98
What is this useful for?
If you want to verify that a user is running your software on the same machine (like a license check), you can generate their HWID and store it in your database. Since it's already hashed you don't expose any raw hardware info.
Notes
- The HWID will change if you replace major hardware components (CPU, disk, etc.)
- On Windows,
VolumeSerialNumbercan change if you reformat your C: drive.MachineGuidis generated by Windows at install time — it's stable day-to-day but will change if Windows is reinstalled. - On Linux,
lsblkis used without sudo — this works on most systems but on some hardware the serial might be empty depending on the driver.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hwidgen-1.0.2.tar.gz.
File metadata
- Download URL: hwidgen-1.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fa63a122bf0b5e9a8fb504c3f206e7fd7c4280a050f55ae46606b1b003c1e4e
|
|
| MD5 |
193e03e6adaec5d67ec55ba052b74a5d
|
|
| BLAKE2b-256 |
2e3cc4971e4753e040c172de26a6f721c901bfe20a3bec7c43762dd33aba0703
|
File details
Details for the file hwidgen-1.0.2-py3-none-any.whl.
File metadata
- Download URL: hwidgen-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a45e1b9390058f8470566bc80672f290a8e1662d463185b13506f2aff4f232a
|
|
| MD5 |
4ec92e862c925091d233d0b734ae5098
|
|
| BLAKE2b-256 |
fd0435861f803329ef43216c3ed1607c0fdf933769a479487d70686ee8d7b731
|