Skip to content

Instantly share code, notes, and snippets.

@localstatic
Created October 16, 2019 20:33
Show Gist options
  • Save localstatic/46fd366e8bb6f12349fd590a4be16f37 to your computer and use it in GitHub Desktop.
Save localstatic/46fd366e8bb6f12349fd590a4be16f37 to your computer and use it in GitHub Desktop.
const crypto = require('crypto');
function randomChars(len) {
const numBytes = len / 2;
return crypto.randomFillSync(Buffer.alloc(numBytes), 0, numBytes).toString('hex');
}
randomChars(256);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment