edge-uniqd
v1.0.0
Published
An irreversible ObjectID generator
Downloads
2
Readme
Uniqd
Uniqd is a irreversible ObjectId generator tool. Need a unique id for something? Uniqd is for you.
How to use?
Simple, just install it, require it and use it
- Install it:
npm install edge-uniqd
- Require it:
let uid = require('edge-uniqd');
console.log(uid); // 00a4acfcdf2205cb89e8ea721e8def45
Under the hood
Uniqd will always return a 32bit ObjectID string, but what makes it really unique and irreversible? Well, first of all the script generate enough entropy taking some special data of the PC, like:
- The time in seconds at the momment of the exection.
- The ProcessId (pid).
- The fingerprint of your PC.
- A random 16bits ID string.
The fingerprint is where all the "heavy" entropy is made because the script makes a big string with this data:
- freemem
- homedir
- hostname
- uptime
- user
- mac-adress
- IP
Then we take this full data an hash it with crypto.createHash
and the md5
algoritm... the result is an irreversible 32bit hasehd string.