2
0

Improved repeat generation of master password suggestions.

This commit is contained in:
Maarten Billemont 2020-04-02 16:13:12 -04:00
parent c4abdb6d49
commit 39c6d5668a

View File

@ -36,13 +36,18 @@ done
template=${template:-${templates[$((RANDOM % ${#templates[@]}))]}} template=${template:-${templates[$((RANDOM % ${#templates[@]}))]}}
printf 'sentence: ' while true; do (
while read -n1 character && [[ $character ]]; do printf 'sentence: '
category=${categoryByCharacter["$character"]} while read -n1 character && [[ $character ]]; do
read p word < <(getword "$category" "$pop_limit") category=${categoryByCharacter["$character"]}
(( permutations *= p )) read p word < <(getword "$category" "$pop_limit")
printf '%s ' "$word" (( permutations *= p ))
done <<< "$template" printf '%s ' "$word"
echo done <<< "$template"
printf 'permutations: %s, entropy: ~%.1f bit\n' "$permutations" "$(bc -l <<< "l($permutations) / l(2)")" echo
printf 'permutations: %s, entropy: ~%.1f bit\n' "$permutations" "$(bc -l <<< "l($permutations) / l(2)")"
read -s -n 1 -p 'Generate another? [Yn]' && echo || break
[[ $REPLY = n ]] && break
); done