How to get the MD5 hash of a string directly in the terminal?

You can also say something like this :

~$ echo -n Welcome | md5sum
83218ac34c1834c26781fe4bde918ee4  -

It basically does the same thing as described by @enzotib, but is perhaps a bit simpler.


Very simple, it accepts stdin, so

md5sum <<<"my string"

To avoid the trailing newline added by the shell:

printf '%s' "my string" | md5sum

$ echo -n 123456 | md5sum | awk '{print $1}'
e10adc3949ba59abbe56e057f20f883e

you can create a shell script.

For example,the script name is md5.sh:

#!/bin/bash

echo   -n   $1 | md5sum | awk '{print $1}'

permission execute:

 chmod +x md5.sh

Then:

$ md5.sh 123456
e10adc3949ba59abbe56e057f20f883e

If your system is macOS. You need to modify this script:

$ echo -n 123456 | md5 | awk '{print $1}' 
e10adc3949ba59abbe56e057f20f883e