Skip to content

Instantly share code, notes, and snippets.

@hbro
Created November 6, 2023 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbro/00b91721f7a39f835d9e78f7c254dea0 to your computer and use it in GitHub Desktop.
Save hbro/00b91721f7a39f835d9e78f7c254dea0 to your computer and use it in GitHub Desktop.
Random Passphrase Generator
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
amount=${1:-1}
# curl -s 'https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-no-swears.txt' | awk 'length($0) > 6 && length($0) < 12' > passphrase-words.txt
source='passphrase-words.txt'
for n in $(seq 1 $amount); do
pw=''
for i in {1..3}; do
word=$(shuf -n 1 "${SCRIPT_DIR}/${source}" | sed -e "s/\b\(.\)/\u\1/g")
pw="${pw}${word}-"
done
no=$(($RANDOM % 100))
pw="${pw}${no}"
echo "$pw"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment