Use openssl command to generate number of pseudo-random bytes, perform base64 encoding and truncate the result to specified number of characters as it will be padded
openssl rand -base64 16 | colrm 17
output: ebT+2wJlhJomwnCy
openssl rand -base64 8
output: hEFxJh0bnkU=
openssl rand -hex 8
output: a0c6c32b2cb54729