Skip to content

Instantly share code, notes, and snippets.

@lukas-buergi
Created June 7, 2012 20:16
Show Gist options
  • Save lukas-buergi/2891307 to your computer and use it in GitHub Desktop.
Save lukas-buergi/2891307 to your computer and use it in GitHub Desktop.
Password generating script
#!/bin/sh
#Generates passwords which should be secure enough
#no matter how paranoid you are using "pwgen"
length=64
number=1
n=1024
salt="FG3OHsU~\-Y?D),"`eRG7}Z]<W9l*YCCr%'8b|K\o@hD>JwRwX:Xy#vC/s@JF,Y&" # CHANGE THIS!
if test -n "$(echo $1 | grep -oe '^[0-9][0-9]*$')"; then
echo "Setting length to $1"
length=$1
if test -n "$(echo $2 | grep -oe '^[0-9][0-9]*$')"; then
echo "Setting number to $2"
number=$2
if test -n "$(echo $3 | grep -oe '^[0-9][0-9]*$')"; then
echo "Setting number of iterations to $3"
n=$3
if test -n "$4"; then
echo "Setting salt to $4"
salt=$4
fi
fi
fi
fi
echo -n "Masterpassword: "
read pw
echo -n "Variable part of your password: "
read varpw
echo "Be patient or change number of iterations to something matching your computer..."
i=0; while test $i -lt $n; do
pw=$(echo "$pw $varpw $salt" | md5sum | sha1sum | sha512sum | rhash -a -)
i=$(($i+1))
done
echo "Your generated password(s):"
echo "1234567891111111111222222222233333333334444444444555555555566666"
echo " 0123456789012345678901234567890123456789012345678901234"
echo $salt > /tmp/stupidtempfilebypwgen.sh
pwgen -syH "/tmp/stupidtempfilebypwgen.sh#$pw" $length $number
echo "Version without special characters for stupid websites:"
pwgen -sH "/tmp/stupidtempfilebypwgen.sh#$pw" $length $number
rm /tmp/stupidtempfilebypwgen.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment