Generating Random Bytes On the Command Line with OpenSSL
I've recently needed to generate an AES encryption key for a new project I've been working on.
I needed to generate a specific number of bytes, and fortunately the OpenSSL CLI came to the rescue with openssl rand
:
# raw bytes
openssl rand 32
# as base64
openssl rand -base64 32
# as a hex representation
openssl rand -hex 32