Skip to content

Instantly share code, notes, and snippets.

@Codesleuth
Last active February 7, 2018 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Codesleuth/f4855197d8c3246c1b8dee63a19deeb1 to your computer and use it in GitHub Desktop.
Save Codesleuth/f4855197d8c3246c1b8dee63a19deeb1 to your computer and use it in GitHub Desktop.
Node.js random password
const crypto = require('crypto')
function createRandomPassword() {
return new Promise((resolve, reject) => {
crypto.randomBytes(32, (err, buf) => {
if (err) return reject(err)
resolve(buf.toString('hex'))
})
})
}
createRandomPassword().then((pass) => {
console.log(pass)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment