Browse Source

doc: crypto.randomBytes does not block when async

It may not return random bytes right away, but when called
asynchronously it will not block.

PR-URL: https://github.com/nodejs/node/pull/14993
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
canary-base
Sam Roberts 7 years ago
parent
commit
68321b5cb0
  1. 3
      doc/api/crypto.md

3
doc/api/crypto.md

@ -1717,7 +1717,8 @@ console.log(
`${buf.length} bytes of random data: ${buf.toString('hex')}`); `${buf.length} bytes of random data: ${buf.toString('hex')}`);
``` ```
The `crypto.randomBytes()` method will block until there is sufficient entropy. The `crypto.randomBytes()` method will not complete until there is
sufficient entropy available.
This should normally never take longer than a few milliseconds. The only time This should normally never take longer than a few milliseconds. The only time
when generating the random bytes may conceivably block for a longer period of when generating the random bytes may conceivably block for a longer period of
time is right after boot, when the whole system is still low on entropy. time is right after boot, when the whole system is still low on entropy.

Loading…
Cancel
Save