pasta_scripts

some useful scripts
git clone https://git.pastanoggin.com/pasta_scripts.git
Log | Files | Refs | README | LICENSE

commit 2df2facb7ac1d124f5543b875fc3199cd25e3283
parent 9346f86cf71d70878426fcce33e52c43d7e5a4f7
Author: boredpasta <boredpasta@tutanota.com>
Date:   Sat, 15 Mar 2025 22:17:28 +0200

badphrase: add diceware support via -d

Diffstat:
Mbadphrase | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/badphrase b/badphrase @@ -4,6 +4,7 @@ set -e charmin=0 charmax=0 copy=0 +diceware=0 entropymin=128 includenames=0 verbose=0 @@ -11,13 +12,14 @@ wordlist=/usr/share/dict/words wordnum=8 usage() { - echo "usage: ${0##*/} [-chiv] [-e entropymin] [-l wordlist] [-m charmax] \ + echo "usage: ${0##*/} [-cdhiv] [-e entropymin] [-l wordlist] [-m charmax] \ [-n charmin] [-w wordnum]" 1>&2 } -while getopts ce:hil:m:n:vw: arg; do +while getopts cde:hil:m:n:vw: arg; do case $arg in c) copy=1;; + d) diceware=1;; e) entropymin=${OPTARG};; h) usage; exit;; i) includenames=1;; @@ -42,12 +44,19 @@ fi # password generation pipeline +# extract 2nd column if we're on a diceware list +awk -v diceware="$diceware" 'BEGIN { + if (diceware) + rec = 2 + else + rec = 1 +} +{ print $rec }' "$wordlist" | \ # filter and shuffle the wordlist -grep -x "${re_class}\{${charmin},${charmax}\}" "$wordlist" | sort -R | \ +grep -x "${re_class}\{${charmin},${charmax}\}" | sort -R | \ # test entropy against $entropymin and if that worked print first $wordnum lines { awk -v prog="${0##*/}" -v entropymin="$entropymin" -v wordnum="$wordnum" -v \ -verbose="$verbose" ' -NR <= wordnum { line[NR] = $0 } +verbose="$verbose" 'NR <= wordnum { line[NR] = $0 } END { perms = NR # show entropy