Nat! bio photo

Nat!

Senior Mull

Twitter Github Twitch

Small shell script to generate passwords

#! /bin/sh
#
# Coded 2011 by Nat! - Mulle kybernetiK
#
# Public Domain
#
# Creates a password with pwgen 
#
#    http://sourceforge.net/projects/pwgen
#
# Advantages of passwords generated with this
# code:
# 
# 1) are "green" in Mac OS X password security 
#    check
# 2) do not contain characters that can be 
#    easily confused with one another in 
#    non-serif fonts
# 3) do not contain z and y or any special 
#    characters, so german or english keyboard 
#    doesn't make a difference
# 
OPTS="-s -B -c -n"

LENGTH=${1:-24}
shift

USER_OPTS="$*"
if [ "$USER_OPTS" != "" ]
then
   OPTS="$USER_OPTS"
fi

pw=""

while [ "$pw" = "" ]
do
    candidate=`pwgen $OPTS -1 $LENGTH 1`
    pw=`echo "$candidate" | grep -v '[zZyY0OlI1]'`
done

echo "$pw"