Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a unique PC ID via Electron?

Is it possible to get a unique PC/Device ID via Electron so I can save PC/Device ID to MySQL Server on the cloud? If this is not possible then what other option I have?

The purpose of this to limit how many device they can use Electron App.

like image 513
I'll-Be-Back Avatar asked Aug 03 '16 20:08

I'll-Be-Back


2 Answers

Take a look of the following example.

import {machineId, machineIdSync} from 'node-machine-id';

// Asyncronous call with async/await or Promise

async function getMachineId() {
    let id = await machineId();
    ...
}

machineId().then((id) => {
    ...
})

// Syncronous call

let id = machineIdSync()
// id = c24b0fe51856497eebb6a2bfcd120247aac0d6334d670bb92e09a00ce8169365
let id = machineIdSync({original: true})
// id = 98912984-c4e9-5ceb-8000-03882a0485e4

You can take a look in this package automation-stack/node-machine-id for more details. I think this is what you are looking for.

like image 195
Masihur Avatar answered Nov 08 '22 01:11

Masihur


Take a look at the os module in nodejs.

You should be able to string together a few of these values to correctly identify unique PC/Devices.

like image 1
S. Donnelly Avatar answered Nov 08 '22 00:11

S. Donnelly