Simple UUID generator - Node.js Security

Node.js examples for Security:GUID

Description

Simple UUID generator

Demo Code


'use strict';/*from   www  .  j a  va  2s  . c o m*/

// Simple UUID generator
var UUIDGenerator = function UUIDGenerator() {
  function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
               .toString(16)
               .substring(1);
  }

  return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
        s4() + '-' + s4() + s4() + s4();
};

module.exports = UUIDGenerator;

Related Tutorials