genpass
- GenPass
#!/bin/bash # Beforehand, do these things; # The grep gives all the four letter lower-case words - avoids names # grep -E -o '^[a-z]{4}$' /usr/share/dict/words > /tmp/words # comm -13 ~/bin/sw.txt /tmp/words.txt > ~/bin/words ; rm /tmp/words # Line above removes the swear words (sw.txt). Words=~/bin/words # Minimum length of Pass Len=15 # If a number was passed as an argument, set length to it [[ ${1} == ?(-)+([0-9]) ]] && Len=${1} Count=1 # If two numbers are passed in, give a list of that many passphrases [[ ${2} == ?(-)+([0-9]) ]] && Count=${2} True=1 False=0 Sym='~!@#$%^&*-' Num='1234567890' SymCnt=${#Sym} NumCnt=${#Num} Loop=1 while [ ${Loop} -le ${Count} ] do TorF=$(( RANDOM % 2 )) First=$(shuf -n 1 ${Words}) String=${First^} while [ ${#String} -le ${Len} ] do if [ ${TorF} -eq ${True} ]; then TorF=${False} String+="${Sym:$(($RANDOM%${SymCnt})):1}" else TorF=${True} String+="${Num:$(($RANDOM%${NumCnt})):1}" fi Next=$(shuf -n 1 ${Words}) String+=${Next^} done echo ${String} ((Loop++)) done
genpass.txt · Last modified: by steve
