1.1.0 • Published 5 years ago
genpwd v1.1.0
Install with yarn global add genpwd
or npm i -g genpwd
for command line.
Add as dependency if you need it in code.
To use on command line just do,
# by default will generate password between 100 and 140 characters
genpwd
# or if you want a certain length
genpwd 64
# or using the alias
pwdgen 72
You can also just set it up directly...
sudo nano /usr/bin/genpwd
#!/usr/bin/env node
process.title = 'genpwd'
let args = process.argv.slice(0);
args.shift();
args.shift();
function rnum() {
return Math.floor(Math.random() * 1000000000);
}
let size = 100 + rnum() % 40;
if (args.length > 0) {
size = parseInt(args[0]);
}
// everything, except 0, 1, l, o, O
let keys = '23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'.split('');
let pass = [];
for (let i = 0; i < size; ++i) {
pass.push(keys[rnum() % keys.length]);
}
console.log();
console.log(' ' + pass.join(''));
console.log();
sudo chmod u+x /usr/bin/genpwd