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"
$1$UwcEHfFx$pv99SO2tq3MZ5u2JtTN.O0

A password is converted to SHA256-based algorithm.

openssl passwd -5 "TopSecret"
$5$6wC.6bysAZzl1zAm$758mNsbX6d.Uzhrm1eAtF3ftrWBgnYi/BES8tSYgKR1

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

openssl passwd -5 password "TopSecret"
$5$6wC.6bysAZzl1zAm$758mNsbX6d.Uzhrm1eAtF3ftrWBgnYi/BES8tSYgKR1
$5$Po.hbT1imQPmydXm$seJP5igIfO0NmTLfx6IcBxrgU7Hh2HthpJ9VTqWWag9

This input convert to SHA512-based password algorithm.

openssl passwd -6 "TopSecret"
$6$CRY0sZkUObU1tIMg$JFM8Artzxz6efj3kVTMyfXimOD.cSZB3VAh3a7pShjJBLiiU598D0YCKCsyBaOXvhwiJG7Onf4Djru2XjMBKf.

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

openssl passwd -apr1 "TopSecret"
$apr1$cVLBkacR$hKouNKpKP0XUkOoNfsPBx/

 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

Parameters:
 password            Password text to digest (optional)

Conclusion

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 / 5. Vote count:

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

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

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