Computer generated random numbers have always interested. When I was learning BASIC one of the games I created was a random number guesser. The computer would generate a random number and then the player would have to guess which number the computer picked! This was the first time writing code made me feel like a magician.
These days PRNG’s (Pseudorandom number generator) are much more complex and I don’t fully understand. And CSPRNG (Cryptographically secure pseudorandom number generator) are even more interesting. And just because I don’t understand doesn’t mean I don’t enjoy randomness any less!
This command will generate 128 bytes of randomness and encode it as a hex string.
openssl rand -hex 128
This command will generate 128 bytes of randomness and encode it as a base64 string.
openssl rand -base64 128
The randomness generated won’t always be characters you can read, but binary bytes of random bits. This is why we output it as hex or base64.