From 39c6d5668a827508766109c2b05bcadd3b7c04b5 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 2 Apr 2020 16:13:12 -0400 Subject: [PATCH] Improved repeat generation of master password suggestions. --- platform-independent/scripts/mpw_mkpw | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/platform-independent/scripts/mpw_mkpw b/platform-independent/scripts/mpw_mkpw index 52771d7a..299e9dc1 100755 --- a/platform-independent/scripts/mpw_mkpw +++ b/platform-independent/scripts/mpw_mkpw @@ -36,13 +36,18 @@ done template=${template:-${templates[$((RANDOM % ${#templates[@]}))]}} -printf 'sentence: ' -while read -n1 character && [[ $character ]]; do - category=${categoryByCharacter["$character"]} - read p word < <(getword "$category" "$pop_limit") - (( permutations *= p )) - printf '%s ' "$word" -done <<< "$template" -echo -printf 'permutations: %s, entropy: ~%.1f bit\n' "$permutations" "$(bc -l <<< "l($permutations) / l(2)")" +while true; do ( + printf 'sentence: ' + while read -n1 character && [[ $character ]]; do + category=${categoryByCharacter["$character"]} + read p word < <(getword "$category" "$pop_limit") + (( permutations *= p )) + printf '%s ' "$word" + done <<< "$template" + 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