Generating random strings with openssl

Quickly need a string of random characters? Just use the ‘openssl’ command like this:

benjamin@plug:~$ openssl rand -hex 20
3e7e9c366c16752d5cca56dd99bd8f02cfcdc16

Update 2017-01-10

I’m always greatful when people take the time to write me an e-mail that can improve a post. So this update is brought to you by Robert, thank you very much! By his benchmarks the below method is about 100% quicker (it could however be a bit less accurate but sometimes speed is more important):

benjamin@nas:~$ od -An -x -N 20 /dev/random|tr -d " \n"
807d5a0f1d6ae58e225cd37b8e35f3a15733813e