small pixel drawing of a pufferfish dotfiles

bin/pwgen

1 2 3 4 5 6 7 8 9 10 11
#!/bin/sh
#
# generate a password of N length

pass_length="$1"

# Regarding usage of '/dev/urandom' instead of '/dev/random'.
# See: https://www.2uo.de/myths-about-urandom
pass=$(LC_ALL=C tr -dc "_A-Z-a-z-0-9" 2> /dev/null < /dev/urandom |
    dd ibs=1 obs=1 count="${pass_length:-50}" 2>/dev/null)
printf "$pass\n"