From 8b5599ec84bbb192a023d5c33a7cb5ae696e548f Mon Sep 17 00:00:00 2001 From: Emil Bay Date: Mon, 30 Apr 2018 21:15:12 +0200 Subject: [PATCH] Update randombytes.js --- randombytes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/randombytes.js b/randombytes.js index d4dcc75..c19a660 100644 --- a/randombytes.js +++ b/randombytes.js @@ -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) }