From a4669437696aa7d67f9c86d9fd7445a5a7e9ed4c Mon Sep 17 00:00:00 2001 From: Dawid Rusnak Date: Sat, 6 Feb 2021 12:08:21 +0100 Subject: [PATCH] crypto: use primordial in favor of prototype chain --- lib/internal/crypto/random.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 48a397f4387c6d..1660ef38873f78 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -8,6 +8,8 @@ const { MathMin, NumberIsNaN, NumberIsSafeInteger, + NumberPrototypeToString, + StringPrototypePadStart, } = primordials; const { @@ -305,7 +307,8 @@ function getHexBytes() { if (hexBytesCache === undefined) { hexBytesCache = new Array(256); for (let i = 0; i < hexBytesCache.length; i++) { - hexBytesCache[i] = i.toString(16).padStart(2, '0'); + const hex = NumberPrototypeToString(i, 16); + hexBytesCache[i] = StringPrototypePadStart(hex, 2, '0'); } } return hexBytesCache;