I essentially use the following:
base64 </dev/urandom | head -c $COUNT | xargs -0
LANG=C tr -dc "[:print:]" < /dev/urandom | fold -w 32 | head -n 1
I essentially use the following: