Skip to content

Commit 9aa1f14

Browse files
committed
Shortened crypto.randomInt inits for Node.js env
1 parent b280881 commit 9aa1f14

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

generate-ip/src/generate-ip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// IMPORT secure crypto RNG
77
let randomInt;
88
try { // to use Node.js module
9-
randomInt = require('crypto').randomInt;
9+
({ randomInt } = require('crypto'));
1010
} catch (err) { // use browser API or JS method
1111
const webCrypto = window.crypto || window.msCrypto;
1212
randomInt = (min, max) => {

generate-pw/src/generate-pw.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// IMPORT secure crypto RNG
77
let randomInt;
88
try { // to use Node.js module
9-
randomInt = require('crypto').randomInt;
9+
({ randomInt } = require('crypto'));
1010
} catch (err) { // use browser API or JS method
11+
console.error('could not iport crcypto');
1112
const webCrypto = window.crypto || window.msCrypto;
1213
randomInt = (min, max) => {
1314
const randomVal = webCrypto?.getRandomValues(new Uint32Array(1))[0] / 0xFFFFFFFF || Math.random();

0 commit comments

Comments
 (0)