Introduction

There are times when you need a long, unique, and super secure password. OpenSSL has a command called rand that outputs a string of pseudo-random bytes. The random bytes are generated using the RAND_bytes(3) function, which provides a security level of 256 bits, provided it managed to seed itself successfully from a trusted operating system entropy source.

This command is a great way to create secure passwords.

For the commands to work below, you'll need to have OpenSSL installed on your machine.

Generate Passwords

To generate a password, open a terminal window and execute one of the following example commands:

Random Characters Without Any Encoding
    
      openssl rand 30
    
  

This command will create a random string of bytes with a length of 30 without any type of encoding applied to the output.

The string output will look something like this:

    
      !U3�:�ſQ��BM��4�W�s�I&%٣
    
  
Random Characters With Base64 Encoding
    
      openssl rand -base64 30
    
  

This command is the same as the first one, but base64 encoding is applied to the outputted string. The output will look similar to below:

    
      AUXNueZeZazJqjHnnoaSMgsCt0rmXs9Vplt48Cwr
    
  
Random Characters As Hex String
    
      openssl rand -hex 30
    
  

This command is the same as the previous one, but the output is shown as a hex string.

    
      532b40101cab9fbc349e0df73eab54af068e9ad4843dc22ad6c96180bb5c
    
  

Conclusion

Hopefully, this article helps you better understand how to generate a long and unique password with OpenSSL.

Thanks for reading and happy coding!