We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96ddcf6 commit 449c8cbCopy full SHA for 449c8cb
1 file changed
crypto.js
@@ -8,18 +8,15 @@
8
import { Buffer } from 'buffer'
9
10
const parent = typeof window === 'object' ? window : globalThis
11
-
12
-// private global deps
13
-const { getRandomValues } = (parent.crypto ?? {})
14
+const { crypto } = parent
15
16
/*
17
* @param {number} size - The number of bytes to generate. The size must not be larger than 2**31 - 1.
18
* @returns {Promise<Buffer>} - A promise that resolves with an instance of io.Buffer with random bytes.
19
*/
20
export function randomBytes (size) {
21
const tmp = new Uint8Array(size)
22
- const bytes = getRandomValues(tmp)
+ const bytes = crypto.getRandomValues(tmp)
23
return Buffer.from(bytes)
24
}
25
0 commit comments