想了解这一点并学会自己实现 0x7FFFFFF是什么意思,我在哪里可以了解更多信息
var secureRandom = function(count) {
var rand = new Uint32Array(1)
var skip = 0x7fffffff - 0x7fffffff % count
var result
if (((count - 1) & count) === 0) {
window.crypto.getRandomValues(rand)
return rand[0] & (count - 1)
}
do {
window.crypto.getRandomValues(rand)
result = rand[0] & 0x7fffffff
} while (result >= skip)
return result % count
}