mirror of
https://github.com/octoleo/Purse.git
synced 2025-02-06 05:58:34 +00:00
adjustable password max len
This commit is contained in:
parent
8c059073eb
commit
be69cf7099
5
pwd.sh
5
pwd.sh
@ -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}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user