Skip to content

Instantly share code, notes, and snippets.

@akash0x53
Created February 2, 2018 07:44
Show Gist options
  • Save akash0x53/f69e69939804d13cb13a627fc5d28b30 to your computer and use it in GitHub Desktop.
Save akash0x53/f69e69939804d13cb13a627fc5d28b30 to your computer and use it in GitHub Desktop.
Generate random password
genpass()
{
#usage: genpass some-random-website.com 12
#generate random password for some-random-website.com and saves in ~/.pass
FOR=$1
LEN=$2
shift
if [ "$LEN" == "" ];then
LEN=8
fi
paswd=$(head -c200 /dev/urandom |tr -cd [:alnum:]+[\!\@\#\$]|head -c $LEN)
echo "$paswd"|xclip -selection c
echo "Copied to clipboard"
if [ "$FOR" == "" ];then
FOR=$(date)
fi
echo "${FOR}: $paswd" >> ~/.pass
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment