The new LTS 1.1.1 version of OpenSSL is out.
How can I upgrade to it using homebrew on MacOS?
Using brew:
brew update
brew install openssl@1.1
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile
# Verify
openssl version
# OpenSSL 1.1.1c 28 May 2019
https://stackoverflow.com/a/56639316 is a good canonical answer, but if you're looking for something simpler / one-off you may be able to get by with just this:
$ brew install openssl@1.1
$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 1.1.1g 21 Apr 2020
So you could do something like this for example:
$ /usr/local/opt/openssl/bin/openssl rand -hex 32
a37d26158b53c8b43faa26ce8291fec9
If you don't have brew
on your computer you can install it in one-line by following the instructions here:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Same thing as the accepted answer but please do a source ~/.bash_profile for this to work.