Skip to content

Instantly share code, notes, and snippets.

@9ete
Last active August 29, 2015 14:06
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 9ete/3c1b821058bc675035fd to your computer and use it in GitHub Desktop.
Save 9ete/3c1b821058bc675035fd to your computer and use it in GitHub Desktop.
Command line password generator. Setup an alias and you're good to go.
#!/bin/bash
echo " "
echo "Password Length(#1-100):"
read PLENGTH
#return date in number format
DATE=$(date +%s)
#create password string of 4 letters
PASSWORD1=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
#create password string of random numbers
PASSWORD2=`echo "((($RANDOM * $DATE)/$RANDOM)/$RANDOM)/100" | bc`
#create password string of 5 letters
PASSWORD3=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 1)
#create password string of random numbers
PASSWORD4=`echo "(($RANDOM * $RANDOM)/$RANDOM)/100" | bc`
#create password string of 4 letters
PASSWORD5=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
PASSWORD=$PASSWORD1$PASSWORD2$PASSWORD3$PASSWORD4$PASSWORD5
echo " "
echo $PASSWORD | sha256sum | base64 | head -c $PLENGTH
echo " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment