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 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"
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 4 comments… read them below or add one }
Reading from standard input:
$ md5sum -
a little script:
#!/bin/bash
echo $1
echo $1 | md5sum
$ ./md5 hallo
hallo
aee97cb3ad288ef0add6c6b5b5fae48a -
The “-” declares, that this message comes from standard input
greets
Remember that md5 should only used for file hash now, in recent days linked_in had a major password leakage for using md5…
md5 and password leaked.
You’re an idiot mate
Thanks, i’ll write this on my tombstone!