Update randombytes.js

This commit is contained in:
Emil Bay 2018-04-30 21:15:12 +02:00
parent 919896d2bb
commit 8b5599ec84

View File

@ -6,7 +6,7 @@ var randombytes = (function () {
function browserBytes (out, n) {
for (let i = 0; i < n; i += QUOTA) {
crypto.getRandomValues(out.subarray(i, i + Math.min(n - i, QUOTA)))
crypto.getRandomValues(new Uint8Array(out.buffer, i, Math.min(n - i, QUOTA)))
}
}
@ -36,5 +36,5 @@ Object.defineProperty(module.exports, 'randombytes', {
module.exports.randombytes_buf = function (out) {
assert(out, 'out must be given')
randombytes(out, out.length)
randombytes(out, out.byteLength)
}