Hi,
I want to use bash to create a md5sum from a string.
I tried md5sum, but it expect a file as input.
Solved: bash create md5 from string
Solved: bash create md5 from string
Last edited by mister_v on Wed Oct 09, 2013 7:45 pm, edited 1 time in total.
Re: bash create md5 from string
You can pipe it using |
(You need option -n because else md5sum will calculate the string with newline char.)
should give something like:
if you don't like the - at the end
Code: Select all
echo -n "test" | md5sum
should give something like:
Code: Select all
098f6bcd4621d373cade4e832627b4f6 -
Code: Select all
echo -n "test" | md5sum | gawk '{ print $1 }'
Re: bash create md5 from string
Thanks.
Indeed without -n the bash md5 check is not the same as with my PHP md5 check.
Indeed without -n the bash md5 check is not the same as with my PHP md5 check.