Generate Password Hash using OpenSSL

Generate Password Hash using OpenSSL

OpenSSL can be used to generate SSL certificates, encrypt and decrypt data, generate hashes or perform other operations related with cryptography. This tutorial shows how to generate a password hash using OpenSSL.

The openssl passwd command can be used for generating password hashes. For example, to generate password hash using MD5 based BSD password algorithm, use the following command:

openssl passwd -1 yourpass

Output example:

$1$8cJnlmP7$/5kEkAiHaleP9AgddPlh50

By default, random salt is used, but it can be provided with -salt option:

openssl passwd -salt yoursalt -1 yourpass

Output:

$1$yoursalt$LMoRi46cR1zxgcXo9KtfV1

Other password hashing algorithms supported as well.

No.Command optionDescription
1.-1MD5 based BSD password algorithm.
2.-5SHA256 based algorithm defined by Ulrich Drepper.
3.-6SHA512 based algorithm defined by Ulrich Drepper.
4.-apr1APR1 algorithm (Apache variant of the BSD algorithm).
5.-aixmd5AIX MD5 algorithm (AIX variant of the BSD algorithm).

Note: the -crypt option was removed in OpenSSL 3.0.

Leave a Comment

Cancel reply

Your email address will not be published.