[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17997: md5sum adds a new line at the end of the input
From: |
Eric Blake |
Subject: |
bug#17997: md5sum adds a new line at the end of the input |
Date: |
Fri, 11 Jul 2014 09:47:12 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
tag 17997 notabug
thanks
On 07/11/2014 02:48 AM, address@hidden wrote:
> Hello,
>
> I implemented my own MD5 generator.
> It provides the same results as all the online MD5 generators, like for
> instance http://onlinemd5.com/.
>
> But it gives a different result than the GNU md5sum tool.
> So I investigated this : it seems that md5sum adds a newline at the end of
> the input !
No, YOU are adding a newline into the input you are feeding to md5sum.
>
> That is quite easy to test :
> - go to http://onlinemd5.com/, type "test" as text input. The MD5 sum is
> 098f6bcd4621d373cade4e832627b4f6
> - now type in a prompt : "echo test | md5sum". The MD5 sum is
> d8e8fca2dc0f896fd7cb4cb0031ba249
Try this:
echo test | od -tx1z
printf test | od -tx1z
Notice the difference? If you use echo, you are passing a newline into
md5sum, and md5sum is doing the right thing. Use printf instead of
echo, and you will get the results you want.
As this is a usage error and not a bug, I'm closing this report. But
feel free to ask further questions as needed.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature