# generate random characters by reading '/dev/urandom' with the
# 'tr' command to translate the random bytes into a
# configurable character set.
# the 'dd' command is then used to read only the desired length.
# regarding usage of '/dev/urandom' instead of '/dev/random'.
# see: https://www.2uo.de/myths-about-urandom
#
# $1 = number of chars to receive
# $2 = filter for the chars
rand_chars() {
  LC_ALL=C tr -dc "$2" </dev/urandom | dd ibs=1 obs=1 count="$1" 2>/dev/null
}
