2020-03-20 04:06:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
########################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 2020.03.18
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
########################################################################
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
|
########################################################################
|
|
|
|
# \\///
|
|
|
|
# qo-op
|
|
|
|
#############
|
|
|
|
##########################
|
|
|
|
#######################################
|
|
|
|
####################################################
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$")
|
|
|
|
# Default is 6 words passphrase
|
|
|
|
if [[ "$MOTS" == "" ]]; then MOTS=6; fi
|
|
|
|
WORDCOUNT=${1-$MOTS}
|
|
|
|
# Download the wordlist
|
|
|
|
# wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null
|
|
|
|
# print a list of the diceware words
|
2020-05-09 19:23:24 +02:00
|
|
|
cat $MY_PATH/diceware-wordlist.txt | \
|
|
|
|
awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' | \
|
2020-03-20 04:06:36 +01:00
|
|
|
# randomize the list order
|
2020-05-09 19:23:24 +02:00
|
|
|
shuf --random-source=/dev/urandom | \
|
2020-03-20 04:06:36 +01:00
|
|
|
# pick the first n words
|
2020-05-09 19:23:24 +02:00
|
|
|
head -n ${WORDCOUNT} | \
|
2020-03-20 04:06:36 +01:00
|
|
|
# pretty print
|
|
|
|
tr '\n' ' '
|
|
|
|
echo
|