Skip to content

Instantly share code, notes, and snippets.

@ngsw
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngsw/8bcd49432de6339dd721 to your computer and use it in GitHub Desktop.
Save ngsw/8bcd49432de6339dd721 to your computer and use it in GitHub Desktop.
"A random password generator" (via http://www.commandlinefu.com)
# http://www.commandlinefu.com/commands/view/13641/a-random-password-generator#comment
tr -dc '\x15-\x7e' < /dev/urandom| head -c 16 | paste
#
cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32
# 便利:)
passwdgen()
{
n=${1}
cat /dev/urandom |
tr -dc A-Za-z0-9 |
head -c ${n:-8}
}
# passwdgen
#=> BpU2a8kM
# passwdgen
#=> uEv8HD8I
# passwdgen 32
#=> 2IKd3tfogc01MjcNIus9dFJaR4yZ3BID
# passwdgen 1
#=> H
# Very Yoi!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment