#!/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"
