Created
May 11, 2021 18:59
-
-
Save zeandrade/12c1cfc283e7bb1eb1f7033b131a81af to your computer and use it in GitHub Desktop.
generate a random password and save the string in a PDF file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/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