want to understand this and learn to implement it myself what does 0x7FFFFFF mean where can i look to learn more
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
}
User contributions licensed under CC BY-SA 3.0