electron-device-id
v1.0.6
Published
Get a unique machine/device ID on macOS, Windows, Linux, and FreeBSD
Maintainers
Readme
electron-device-id
Get a unique machine/device ID on macOS, Windows, Linux, and FreeBSD. No native dependencies — uses built-in OS commands.
Install
npm install electron-device-idUsage
const { machineId, machineIdSync } = require('electron-device-id');
// Async (recommended)
machineId().then(id => console.log(id));
// Sync
const id = machineIdSync();
console.log(id);By default the ID is hashed with SHA-256. Pass true to get the raw original value:
const raw = machineIdSync(true); // original hardware UUID
const hashed = machineIdSync(); // sha256 hash (default)API
machineId(original?): Promise<string>
Returns a promise that resolves to the machine ID.
| Param | Type | Default | Description |
|---|---|---|---|
| original | boolean | false | Return raw ID instead of SHA-256 hash |
machineIdSync(original?): string
Synchronous version of machineId.
| Param | Type | Default | Description |
|---|---|---|---|
| original | boolean | false | Return raw ID instead of SHA-256 hash |
Platform support
| Platform | Source |
|---|---|
| macOS | ioreg IOPlatformUUID |
| Windows | Registry HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid |
| Linux | /var/lib/dbus/machine-id or /etc/machine-id or hostname |
| FreeBSD | smbios.system.uuid or kern.hostuuid |
License
MIT
