Last active
August 3, 2017 03:38
-
-
Save suhaotian/ba205dbae83ff511f2d613500d2d79ca to your computer and use it in GitHub Desktop.
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
/* | |
*/ | |
module.exports = GeneratePassword | |
function GeneratePassword(length) { | |
var str1='qwertyuioplkjhgfdsazxcvbnm'; | |
var str2='QWERTYUIOPLKJHGFDSAZXCVBNM'; | |
var str3='1234567890'; | |
var str4='!@#$%^&*.,'; | |
var str = [str1,str2,str3,str4].join('') | |
var res = ''; | |
for (var i=0; i < length; i++) { | |
var j = getRandomNum(str.length); | |
res = res + str.charAt(j); | |
} | |
return res; | |
} | |
function getRandomNum(cnt) { | |
// between 0 - 1 | |
var rndNum = Math.random() | |
rndNum = parseInt(rndNum * cnt); | |
return rndNum; | |
} |
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 fs = require('fs') | |
const GeneratePassword = require('./password-generator') | |
const server = { | |
"server": "0.0.0.0", | |
"port_password": { | |
}, | |
"timeout": 300, | |
"method": "aes-128-cfb" | |
} | |
for (let i=1; i<=10; i++) { | |
server.port_password[10000+i] = GeneratePassword(16) | |
} | |
for (let i=1; i<=10; i++) { | |
server.port_password[20000+i] = GeneratePassword(16) | |
} | |
fs.writeFile('./users.json', 'utf8', JSON.stringify(server, null, 4), () => { | |
console.log('done') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment