hexo/node_modules/cuid/lib/getRandomValue.js

10 lines
183 B
JavaScript
Raw Normal View History

2023-10-03 11:14:36 +08:00
var crypto = require('crypto');
var lim = Math.pow(2, 32) - 1;
module.exports = function random () {
return Math.abs(crypto.randomBytes(4)
.readInt32BE() / lim);
};