2013
04.28

so i added two different password generator functions into my .zshrc.

one for regular:

function genpasswd() { 
    if [ -z $1 ]; then 
        echo "need a character count"
    else 
        tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${1} | xargs
    fi 
    }


and one for strong:

function genpasswd_strong() { 
    if [ -z $1 ]; then 
        echo "need a character count"
    else 
        tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' < /dev/urandom | head -c ${1} | xargs
    fi 
    }


using them:
% genpasswd 12
Z14QsnEPKvOt
% genpasswd_strong 12
3%^d!Ze}-$_@

simple enough.

here is a link to my .zshrc.

2 comments so far

Add Your Comment
  1. Does `pwgen 10 -N5` work?

    • not pre-installed in some of the distro’s i use. method i use does not need external addons or deps.