Skip to content

Instantly share code, notes, and snippets.

@azizur
Last active April 27, 2024 06:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azizur/b8eb54b505552d913d286345774c70ec to your computer and use it in GitHub Desktop.
Save azizur/b8eb54b505552d913d286345774c70ec to your computer and use it in GitHub Desktop.
Proposal for generating Unique Device Identification (UDI)
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
const hashValue = (data) => {
return hash.update(JSON.stringify(data), 'utf-8').digest('hex');
};
// generate a hash
console.log(hashValue(['userId', 'deviceId']));
// output
// 104a4a7d0908e67ebf91a46ba34b48d846a181d2f41b4df792f943f30bd199f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment