Fwd: Re: [TriLUG] md5sum disagrees with libmd5-rfc and Digest::MD5 <SOLVED, no thanks to me :-)>

Steve Litt slitt at troubleshooters.com
Tue Apr 25 20:06:59 EDT 2006


Dooohhhhh!

Brian Weaver's email address is cmdrclueless, but after reading his email and 
verifying that he is absolutely correct, I now find myself Big King Clueless 
for Life. As several of you said, the echo statement was sending a newline at 
the end, and when I made a file to test, the file ended in a newline because 
I made it with Vim.

Once I used echo -n as Brian suggested, everything worked perfectly.

To Brian and all of you who had suggestions, including the several who 
suggested the ending newline was the problem, thank you. I can now complete 
my project and feel good about all the md5sums I've done in the past 5 years.

SteveT

----------  Forwarded Message  ----------

Subject: Re: [TriLUG] md5sum disagrees with libmd5-rfc and Digest::MD5
Date: Tuesday 25 April 2006 04:24 pm
From: "Brian Weaver" <cmdrclueless at gmail.com>
To: "Triangle Linux Users Group discussion list" <trilug at trilug.org>

Have you considered that your echo statements probably include a
newline character (\n). Try 'echo -n ...'

-Brian

On 4/25/06, Steve Litt <slitt at troubleshooters.com> wrote:
> Hi all,
>
> I have a problem that's killing me, and there seems to be no info on it
> anywhere on the Internet, so I've massively crossposted in hope of an
> answer. If I find one, I'll let all of you know.
>
> I created workalikes for the md5sum command using L. Peter Deutsch's
> libmd5-rfc and Perl's Digest::MD5. Those workalikes agree with each other
> but disagree with the output of the MD5sum program for the same input.
> Unless Digest::MD5 is built from Deutsch's code, this either casts an
> accusing finger at md5sum, or there's some basic fact I don't understand.
>
> Here is an example of all three programs finding an md5 digest in hex
> format for the string "abc":
>
> [slitt at mydesk ~]$ echo abc | md5sum -t
> 0bee89b07a248e27c83fc3d5951213c1  -
> [slitt at mydesk ~]$ echo abc | md5sum -b
> 0bee89b07a248e27c83fc3d5951213c1 *-
> [slitt at mydesk ~]$ md5sum -t abc.txt
> 0bee89b07a248e27c83fc3d5951213c1  abc.txt
> [slitt at mydesk ~]$ md5sum -b abc.txt
> 0bee89b07a248e27c83fc3d5951213c1 *abc.txt
> [slitt at mydesk ~]$ ./deutsch.bin abc
> 900150983cd24fb0d6963f7d28e17f72
> [slitt at mydesk ~]$ /d/at/perl/md5/md5test.pl abc
> Hello world
> 900150983cd24fb0d6963f7d28e17f72
> [slitt at mydesk ~]$
>
> As you can see, the perl program and the program made with Deutsch's code
> agree with each other and disagree with all possible running's of md5sum.
>
> I'm using Mandriva 2006 on an Athlon XP2600 with 1.5GB RAM and a couple
> >200GB hard drives. The md5sum command I'm using is stock.
>
> Below my sig is listings for my perl program using Digest::MD5 and my C
> program using Deutsch's libmd5-rfc code.
>
> Thanks
>
> SteveT
>
> Steve Litt
> Author:
>    * Universal Troubleshooting Process courseware
>    * Troubleshooting Techniques of the Successful Technologist
>    * Rapid Learning: Secret Weapon of the Successful Technologist
> Webmaster
>    * Troubleshooters.Com
>    * http://www.troubleshooters.com
>
>
> #include "md5.h"
> #include <math.h>
> #include <stdio.h>
> #include <string.h>
>
> int main(int argc, char *argv[])
>         {
>         md5_state_t state;
>         md5_byte_t digest[16];
>         int ssi;
>
>         memset(digest, 32, sizeof(digest));
>         md5_init(&state);
>         md5_append(&state, (const md5_byte_t *)argv[1], strlen(argv[1]));
>         md5_finish(&state, digest);
> /*      printf("%s ==md5==> ", argv[1]);*/
>         for(ssi=0; ssi < 16; ssi++)
>                 {
>                 printf("%02x", digest[ssi]);
>                 }
>         printf("\n");
>         }
>
>
> #!/usr/bin/perl -w
> use strict;
>
> use Digest::MD5
>
> print "Hello world\n";
>
>
> my $ctx = Digest::MD5->new;
>
> my $data=$ARGV[1];
> $ctx->add("abc");
> #$ctx->addfile(*FILE);
>
> my $digest;
> $digest = $ctx->hexdigest;
> print $digest, "\n";
> #$digest = $ctx->hexdigest;
> #print $digest, "\n";
> #$digest = $ctx->b64digest;
> #print $digest, "\n";
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/

--

/* insert witty comment here */
--
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/

-------------------------------------------------------

-- 
Steve Litt
Author: 
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Rapid Learning: Secret Weapon of the Successful Technologist
Webmaster
   * Troubleshooters.Com
   * http://www.troubleshooters.com

(Legal Disclaimer) Follow these suggestions at your own risk.



More information about the TriLUG mailing list