Generating Random Bytes On the Command Line with OpenSSL
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
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