Skip to content
Closed
Prev Previous commit
Next Next commit
doc: update examples about crypto.randomBytes
fix outdated examples about crypto.randomBytes to make it clear
  • Loading branch information
JungMinu committed Sep 27, 2015
commit a8af4f3f5f8aacfbe2ce8ed612230fd9312dd0de
4 changes: 4 additions & 0 deletions doc/api/crypto.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ Generates cryptographically strong pseudo-random data. Usage:
console.log('Have %d bytes of random data: %s', buf.length, buf);
});

// sync
var buf = crypto.randomBytes(256);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest to use const?

console.log('Have %d bytes of random data: %s', buf.length, buf);

NOTE: This will block if there is insufficient entropy, although it should
normally never take longer than a few milliseconds. The only time when this
may conceivably block is right after boot, when the whole system is still
Expand Down