#      SRJ 2016-09-20 Create reasonable passwords
# This is ~/bin/TinyPad
# This script produces 26 rows of 3 columns of 13 characters each.
# It was written to create ISO-ID-1 Cards to carry in the wallet, with 
# a letter before each row as a reminder (I use row G for Google passwords
# for example.
Count=${#Chars}   # Length of $Chars
# You can remove specific characters to avoid ambiguity, O or 0 for instance,
# though, if you print this in Courier, the symbols are quite unique.
# This function generates a random number, returns the modulus of that number 
# in the range of 1 to (Number of characters in $Char), and then returns the 
# single character from $Char at that position
Offset=$(($(head -c4 /dev/urandom | od -N2 -tu2 | sed -ne '1s/.* //p')%$Count))
echo "${Chars:${Offset}:1}"
for Row in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
do echo -n "${Row} "
  for Column in 1 2 3
  do for Char in 1 2 3 4 5 6 7 8 9 10 11 12 13
    do echo -n "$(Ran)"
    done  ; echo -n " "
  done ; echo ""
# The 3 embedded loops above spit out the Rows, Columns, and Char to form an
# array that is designed to fit on a credit card for your wallet. 
# For the line below to work properly, you have to install the enscript package,
# then add a media definition in the form;
# Media:	Card		242	153	5	9	228	145 
# to the /etc/enscript.cfg file
# TinyPad | enscript -BM Card --margins=10:9 --output=- -f CourierBold8/9 | ps2pdf - Pad.pdf
# Produces a file, Pad.pdf that can be printed directly with the card printer 
# at the front desk.