Skip to content

Instantly share code, notes, and snippets.

@msawangwan
Last active October 3, 2016 18:16
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 msawangwan/6b06595cd52b7830c07b49c9bfe67ff3 to your computer and use it in GitHub Desktop.
Save msawangwan/6b06595cd52b7830c07b49c9bfe67ff3 to your computer and use it in GitHub Desktop.
[bash][shell] password generator
#!/bin/bash
#+ Password Generator
#+ Author: misha@sawangwan.me
#+ Utilizes the entropy pool to generate a password. If no length
#+ is specified, a default length of 20 is used.
#+ Execute with './' prefix or add to PATH (recommended).
#+ Usage:
#+ genpasswd [pw_length_int_value] OR genpasswd
#+ Example:
#+ ~$ genpasswd 32
#+ More Info: /dev/urandom or /dev/random
len=$1
[ "$1" == "" ] && len=20
RESULT=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${len}; echo)
echo ""
echo "[ +] Password: $RESULT"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment