wspvqg
Last Updated: March 28, 2016
·
1.024K
· petarov
Odxm8uk

Generate unique keys and phrases with OpenSSL and Bash

If you are ever in a situation that you need to generate a large (or small) random string or an authentication key you can combine some of the command line tools available on Linux to realize that goal. For example:

The following command will pull 4096 bytes from the pseudo-random number generator on Linux after which it will produce a sha1 hashed value:

$ dd if=/dev/urandom bs=2 count=2048 | openssl sha1
(stdin)= de07d8a695984fc3556f4f91a244dba5e8e03d8b

The following command will pull 256 bytes from the pseudo-random number generator and it will encode them as base64 string.
This is quite helpful if you need to generate unique phrases for a Wordpress installation.

$ dd if=/dev/urandom bs=16 count=16 | openssl base64 | tr -d '\n'
Say Thanks
Respond
Filed Under