commit 710ac6a9ccd47929ccab19e92a7190c28580b673
parent ee7b1572af1d62d7613cbcb7ca2ac284f3981ad9
Author: noodle <noodle@pastanoggin.com>
Date: Wed, 11 Jun 2025 20:35:06 +0300
refactor
Diffstat:
6 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/badphrase b/badphrase
@@ -1,7 +1,7 @@
#!/bin/sh
# badphrase: generate passphrases or something lol
# diceware example: ./badphrase -dvl /tmp/diceware.wordlist.asc -w 10
-# please use it with diceware bacause all other wordlists suck ToT
+# please use with diceware bacause all other wordlists suck ToT
# yay!
set -e
@@ -36,7 +36,6 @@ while getopts cde:hil:m:n:vw: arg; do
esac
done
shift $((OPTIND - 1))
-
# setup regex
if [ "$includenames" -eq 1 ]; then
re_class='.'
@@ -45,9 +44,7 @@ else
fi
[ "$charmin" -lt 0 ] && charmin=0
[ "$charmax" -le 0 ] && charmax=''
-
# password generation pipeline
-
# extract 2nd column if we're on a diceware list
awk -v diceware="$diceware" 'BEGIN {
if (diceware)
@@ -57,7 +54,7 @@ awk -v diceware="$diceware" 'BEGIN {
}
{ print $rec }' "$wordlist" |
# filter and shuffle the wordlist
-grep -x "${re_class}\{${charmin},${charmax}\}" | 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 }
diff --git a/dec b/dec
@@ -1,8 +1,5 @@
#!/bin/sh
-# decode passwords
-# make sure you've added at least one readable line to the password so you can
-# confirm that the passphrase is correct, as openssl doesn't give errors
-# about wrong passphrases and spits out garbled output instead
+# dec: decrypt passwords
set -e
[ "$#" -ne 1 ] && { echo "usage: ${0##*/} passname" 1>&2; exit 1; }
passfile="$HOME/.passwords/${1}.cha20"
diff --git a/enc b/enc
@@ -1,8 +1,8 @@
#!/bin/sh
-# encode a password from stdin with a passphrase
-# make sure you add at least one readable line to the password so you can
-# confirm that the passphrase is correct, as openssl doesn't give errors
-# about wrong passphrases and spits out garbled output instead
+# enc: encrypt a password from stdin with a passphrase
+# add at least one readable line to the password so you can confirm that the
+# output is correct when you're decrypting later, as openssl doesn't give
+# errors about wrong passphrases and spits out garbled output instead
set -e
[ "$#" -ne 1 ] && { echo "usage: ${0##*/} passname" 1>&2; exit 1; }
mkdir -pm 700 "$HOME/.passwords/"
diff --git a/encfile b/encfile
@@ -1,4 +1,4 @@
#!/bin/sh
-# encade file with a passphrase
+# encfile: encrypt a file with a passphrase
set -e
openssl enc -e -chacha20 -pbkdf2 -iter 10000 -in "$1" -out "$1.cha20"
diff --git a/entropy b/entropy
@@ -1,8 +1,7 @@
#!/bin/sh
-# entropy: calculates the entropy of a password given the password length and
-# number of possiblities
+# entropy: calculate the entropy of a password given it's length and number of
+# possible characters
set -e
-
num=0
[ "$1" = '-n' ] && { num=1; shift; }
[ "$#" -ne 2 ] && { echo "usage: ${0##*/} [-n] possibilites length " 1>&2; exit 1; }
diff --git a/gen b/gen
@@ -1,10 +1,9 @@
#!/bin/sh
-# generate passwordssss
-# range is from ascii space (32) to tilde (126) -> 126-32=96 possibilities
-# which yeilds 256+ bits of entropy at a password length of 40 (can be
-# calculatedwith `entropy 96 40')
+# gen: generate passwordssss (:<)~~~~~
+# the range is from ascii space (32) to tilde (126) -> 126-32+1=95
+# possibilities which yeilds 256+ bits of entropy at a password length of 40
+# (can be calculated with `entropy 95 40')
set -e
-
length=40
[ "$#" -gt 1 ] && { echo "usage: ${0##*/} [length]" 1>&2; exit 1; }
[ "$#" -eq 1 ] && length=$1