Linux / Unix: Generate A MD5 String

I need to generate a md5 hash for given string. It will be used by shell script to generate keys for remote web service or cryptographic application. How do I generate a md5 hash based on any input string under Linux or Unix like operating systems?

You can use md5sum command to compute and check MD5 message digest. This is a default tool on most modern Linux distributions. It generate a md5 hash for given string or words or filenames.

Create a md5 string using md5sum command

Use the following syntax:

echo -n "Your-String-Here" | md5sum

In this example create a md5 hash for wpblog string that can be used by memcached server

 echo -n "wpblog" | md5sum

Sample outputs:

6afedb7a8348eb4ebdbe0c77ef92db4c -

You can store the same in a bash shell variable called hash as follows:

md5="set-string-here"
hash="$(echo -n "$md5" | md5sum )"
echo "$hash"

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Total
0
Shares
Leave a Reply

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

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts