Blame view

node_modules/math-random/node.js 236 Bytes
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
  var crypto = require('crypto')
  var max = Math.pow(2, 32)
  
  module.exports = random
  module.exports.cryptographic = true
  
  function random () {
    var buf = crypto
      .randomBytes(4)
      .toString('hex')
  
    return parseInt(buf, 16) / max
  }