Linux / Unix: Generate A MD5 String
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
You can store the same in a bash shell variable called hash as follows:
hash="$(echo -n "$md5" | md5sum )"
Recommended readingsShare this tutorial on:
Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter → Make a contribution via Paypal/Bitcoin →
Don't Miss Any Linux and Unix Tips Get nixCraft in your inbox. It's free: