mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-08-06 17:48:43 +08:00
14 lines
222 B
JavaScript
14 lines
222 B
JavaScript
var crypto = require('crypto')
|
|
var max = Math.pow(2, 32)
|
|
|
|
module.exports = random
|
|
module.exports.cryptographic = true
|
|
|
|
function random () {
|
|
var buf = crypto
|
|
.randomBytes(4)
|
|
.readUInt32BE(0)
|
|
|
|
return buf / max
|
|
}
|