Skip to content

Instantly share code, notes, and snippets.

@zeandrade
Created May 11, 2021 18:59
Show Gist options
  • Save zeandrade/12c1cfc283e7bb1eb1f7033b131a81af to your computer and use it in GitHub Desktop.
Save zeandrade/12c1cfc283e7bb1eb1f7033b131a81af to your computer and use it in GitHub Desktop.
generate a random password and save the string in a PDF file
# !/bin/sh
# generate a random password and save the string in a PDF file
# 7 letters ( upppers and lowers), except "l" and "O" to better legibility
# 4 numbers (1 to 9)
# 3 special chars of @,! or _
convert --version > /dev/null 2>/dev/null || (echo "Error: you need imagemagick" && exit )
passwd_p1=`tr -dc 'A-NQ-Za-km-z' </dev/urandom | head -c 7`
passwd_p2=`tr -dc '1-9' </dev/urandom | head -c 4`
passwd_p3=`tr -dc '@!_' </dev/urandom | head -c 3`
passwd=`echo ${passwd_p1}${passwd_p3}${passwd_p2} | sed 's/./&\n/g' | shuf | shuf | tr -d "\n"`
mydate=`date +%Y%m%d_%H%M%S`
convert -size 260x60 -font "DejaVu-Sans-Mono" -pointsize 16 -fill black caption:"${passwd}" ${mydate}_yourpass.pdf
echo ${mydate}_yourpass.pdf generated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment