/home/wpollock1/public_html/restricted/ShellScripting/argon
#!/bin/bash
# Use argon2id to generate a very secure password hash.
# As per best advice <https://www.zdnet.com/article/sha-1-collision-attacks-are-now-actually-practical-and-a-looming-danger/>
# I use >= 32MiB of memory, >= 2 rounds, and >= 2 threads (parallelism)
# I also use 22 characters of salt, using most of OWASP's list of
# special characters (not "$" or "'" though).
#
# Written 5/2019 by Wayne Pollock, Tampa Florida USA
export LC_ALL=C
SALT_LEN=22
SALT=$( tr -dc 'A-Za-z0-9!"#%&\()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom |
head -c "$SALT_LEN" )
if [ $# -ne 0 ]
then
PASS="$*"
else
read -rsp 'password: ' PASS
fi
echo "PASS" |argon2 "$SALT" -id -m 16 -t 2 -p 2