Created
October 5, 2018 14:20
-
-
Save tcdw/9a43eb263e02a5c489ccf8e5cd10d4d7 to your computer and use it in GitHub Desktop.
生成密码(Node.js
This file contains hidden or 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 generatePassword = (length) => { | |
const data = []; | |
for (let i = 0; i < length; i += 1) { | |
data.push(Math.floor(Math.random() * 94) + 33); | |
} | |
return Buffer.from(data).toString('utf8'); | |
}; | |
module.exports = generatePassword; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment