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
-
mister_v
- Posts: 203
- Joined: Thu Mar 04, 2010 9:19 pm
Solved: bash create md5 from string
Last edited by mister_v on Wed Oct 09, 2013 7:45 pm, edited 1 time in total.
-
chris
- Site Admin
- Posts: 216
- Joined: Mon Jul 21, 2008 9:52 am
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" | md5sumshould give something like:
Code: Select all
098f6bcd4621d373cade4e832627b4f6 -Code: Select all
echo -n "test" | md5sum | gawk '{ print $1 }'-
mister_v
- Posts: 203
- Joined: Thu Mar 04, 2010 9:19 pm
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.