Skip to content
Prev Previous commit
Next Next commit
crypto: use primordial in favor of prototype chain
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
rangoo94 and aduh95 committed Feb 24, 2021
commit 74b50ed4004112b50488eaa512c9741e867b27f3
5 changes: 4 additions & 1 deletion lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
MathMin,
NumberIsNaN,
NumberIsSafeInteger,
NumberPrototypeToString,
StringPrototypePadStart,
} = primordials;

const {
Expand Down Expand Up @@ -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;
Expand Down