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>
v6.x
Sam Roberts 7 years ago
committed by Myles Borins
parent
commit
4c26913dab
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 3
      doc/api/crypto.md

3
doc/api/crypto.md

@ -1540,7 +1540,8 @@ console.log(
`${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
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.

Loading…
Cancel
Save