From 76eb6b354b2da16dc57b65e4093fa3da5c8fd1eb Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 17 Jul 2017 22:22:52 -0700 Subject: [PATCH] crypto/random: minor. comments. --- lib/crypto/random-browser.js | 10 +++++----- lib/crypto/random.js | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/crypto/random-browser.js b/lib/crypto/random-browser.js index e5592547..fbaf0092 100644 --- a/lib/crypto/random-browser.js +++ b/lib/crypto/random-browser.js @@ -14,21 +14,21 @@ const crypto = global.crypto || global.msCrypto || {}; /** - * Generate some random bytes. + * Generate pseudo-random bytes. * @param {Number} size * @returns {Buffer} */ -exports.randomBytes = function randomBytes(n) { - let data = new Uint8Array(n); +exports.randomBytes = function randomBytes(size) { + let data = new Uint8Array(size); crypto.getRandomValues(data); return Buffer.from(data.buffer); }; if (!crypto.getRandomValues) { // Out of luck here. Use bad randomness for now. - exports.randomBytes = function randomBytes(n) { - let data = Buffer.allocUnsafe(n); + exports.randomBytes = function randomBytes(size) { + let data = Buffer.allocUnsafe(size); for (let i = 0; i < data.length; i++) data[i] = Math.floor(Math.random() * 256); diff --git a/lib/crypto/random.js b/lib/crypto/random.js index 39587794..f2280a9f 100644 --- a/lib/crypto/random.js +++ b/lib/crypto/random.js @@ -12,8 +12,11 @@ const crypto = require('crypto'); -/* - * Misc +/** + * Generate pseudo-random bytes. + * @function + * @param {Number} size + * @returns {Buffer} */ exports.randomBytes = crypto.randomBytes;