Accurate max password length

This commit is contained in:
drduh 2015-07-03 00:29:12 -04:00
parent c8e0f6d494
commit bfeece461b
1 changed files with 3 additions and 2 deletions

5
pwd.sh
View File

@ -76,13 +76,14 @@ gen_pass () {
# Generate a password.
len=40
read -p "Password length? (default: 40, max: 80) " length
read -p "Password length? (default: 40, max: 100) " length
if [[ ${length} =~ ^[0-9]+$ ]] ; then
len=${length}
fi
${gpg} --gen-random -a 0 80 | cut -c -${len}
# base64: 4 characters for every 3 bytes
${gpg} --gen-random -a 0 75 | cut -c -${len}
}