node.js 236B

1234567891011121314
  1. var crypto = require('crypto')
  2. var max = Math.pow(2, 32)
  3. module.exports = random
  4. module.exports.cryptographic = true
  5. function random () {
  6. var buf = crypto
  7. .randomBytes(4)
  8. .toString('hex')
  9. return parseInt(buf, 16) / max
  10. }