Convert password to MD5 or SHA hash algorithm with OpenSSL


A password often needs to be convert to an MD5 or SHA algorithm using OpenSSL to be paste as hash into a SQL table or into a configuration file such as an XML or JSON file.

This is where the OpenSSL Toolkit can be used to convert a password.

Message-Digest Algorithm 5 (MD5) is a popular cryptographic hash function that calculates a 128-bit hash value from any message. Secure Hash Algorithm (SHA) refers to a group of standardized cryptological hash functions and is used to calculate a check value for any digital data and is, among other things, the basis for creating a digital signature.

How to convert a password to MD5-based or SHA algorithm hash with OpenSSL

How to convert password MD5-based

Fire up an terminal shell (Ctrl+Alt+T) or an command prompt and hitopenssl passwdto convert a password to MD5-based algorithm.

openssl passwd -1 "TopSecret"

A password is converted to SHA256-based algorithm.

openssl passwd -5 "TopSecret"

The option password displaying the hash together with text to digest.

openssl passwd -5 password "TopSecret"

This input convert to SHA512-based password algorithm.

openssl passwd -6 "TopSecret"

This input convert MD5-based password Apache variant algorithm using OpenSSL.

openssl passwd -apr1 "TopSecret"

 openssl is also available for windows, the article here shows how to do it.

OpenSSL passwd help is available with this command.

openssl passwd --help
Usage: passwd [options] [password]

General options:
 -help               Display this summary

Input options:
 -in infile          Read passwords from file
 -noverify           Never verify when reading password from terminal
 -stdin              Read passwords from stdin

Output options:
 -quiet              No warnings
 -table              Format output as table
 -reverse            Switch table columns

Cryptographic options:
 -salt val           Use provided salt
 -6                  SHA512-based password algorithm
 -5                  SHA256-based password algorithm
 -apr1               MD5-based password algorithm, Apache variant
 -1                  MD5-based password algorithm
 -aixmd5             AIX MD5-based password algorithm

Random state options:
 -rand val           Load the given file(s) into the random number generator
 -writerand outfile  Write random data to the specified file

Provider options:
 -provider-path val  Provider load path (must be before 'provider' argument if required)
 -provider val       Provider to load (can be specified multiple times)
 -propquery val      Property query used when fetching algorithms

 password            Password text to digest (optional)


This tutorial show you how to convert a password to SHA or MD5-based algorithm.

We use the versatile OpenSSL Toolkit to convert passwords and key phrases. Under no circumstances you should use one of the many online tools on the web, as there is a risk that your password can be misused for malicious attacks.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *