Last active
February 7, 2018 07:25
-
-
Save Codesleuth/f4855197d8c3246c1b8dee63a19deeb1 to your computer and use it in GitHub Desktop.
Node.js random password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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