1
0
mirror of https://github.com/octoleo/Purse.git synced 2024-06-09 09:42:36 +00:00

adjustable password max len

This commit is contained in:
drduh 2015-07-03 11:49:38 -04:00
parent 8c059073eb
commit be69cf7099

5
pwd.sh
View File

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