zshrc and password generator

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.

«
»

Leave a Reply

Your email address will not be published. Required fields are marked *