Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-11-2009, 02:33 PM   #1
Registered: Oct 2005
Location: Switzerland
Distribution: Ubuntu
Posts: 33

Rep: Reputation: 16
MD5 confusion / giving conflicting results...

When I do ...
echo 'HelloWorld' | md5
I get..


Where as when I do (what I think is) the same via an online website (eg ) I get ...


Can someone help explain why they are different please because I would have thought they should give the same result.

Many thanks,
Old 05-11-2009, 02:42 PM   #2
LQ Newbie
Registered: Dec 2006
Posts: 3

Rep: Reputation: 0
echo outputs a trailing newline.

$ echo -n 'HelloWorld' | md5sum
68e109f0f40ca72a15e05cc22786f8e6 -

$ echo 'HelloWorld' | md5sum
6df4d50a41a5d20bc4faad8a6f09aa8f -
Old 05-11-2009, 02:45 PM   #3
harry edwards
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
Also, consider that some md5 algorithms only read a section of the file; let's say the first 2k; others may read the entire file. This can obviously lead to discrepancy and I think will explain what you are seeing.

The reason is related to efficiency; for, example if you had ten 2GB files on a network share the md5 program that reads the first 2k would be faster than than the program that requires the entire file.

Last edited by harry edwards; 05-11-2009 at 02:47 PM.
Old 05-11-2009, 03:03 PM   #4
Registered: Oct 2005
Location: Switzerland
Distribution: Ubuntu
Posts: 33

Original Poster
Rep: Reputation: 16
Ahhhh ha !
Ok thanks very much (was beginning to worry that I've got some different 'version' of md5 !
Thanks vm
Old 08-01-2009, 06:04 PM   #5
LQ Newbie
Registered: Aug 2009
Location: Germany
Distribution: Debian, OpenWrt
Posts: 23

Rep: Reputation: 1
Other reasons:

#1 Where do you invoke md5sum?
On Linux: binary and text files are the same.
On Windows: binary and text files are different.

#2 How do you invoke md5sum?
With --text (default on Linux) or --binary (default on Windows).

Always use the correct parameter depending on the file format (binary or text) to create a cross-platform compatible checksum.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ethtool giving conflicting answers!! kamalsivadas Linux - Networking 1 04-23-2009 07:51 AM
hostname -f giving no results cafeelgood Linux - Networking 1 08-20-2007 07:14 PM
df and du giving contradictory results ? wearetheborg Linux - General 7 02-03-2006 04:49 PM
Conflicting results with usb memory sticks Taliesin Linux - Hardware 4 03-31-2005 12:43 AM
MonoDevelop gives conflicting results nagromo Linux - Software 0 12-11-2004 01:00 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:20 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration