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:

Build A Hacker News Clone
Learn how to build and deploy a full-stack, production-ready application with React.js, Node.js, and MongoDB.
View Course
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:

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.



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

Thanks for reading and happy coding!