Created
October 31, 2011 01:37
-
-
Save ryan-blunden/1326709 to your computer and use it in GitHub Desktop.
Random password generator
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
#!/usr/bin/env node | |
/** | |
* Create a random password of variable length and copy it to the clipboard | |
* Usage: 'random_password 4' produces a 4 character password | |
*/ | |
var pass = ''; | |
while(pass.length < process.argv[2]) { | |
pass += String.fromCharCode(Math.floor(35 + (Math.random() * 91))); | |
}; | |
require('child_process').exec('echo '+ pass.replace('`', ' ') +' | pbcopy', function(error, stdout, stderr) { | |
console.log('Password copied to clipboard'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment