in reply to Newbie doesn't understand Digest::MD5

My guess is that you're getting bitten by not setting the binary mode on the filehandle you're reading from. This is done easiest by using the binmode function:

binmode STDIN; $md5->addfile(\*STDIN);

Another possibility might be that the "echo" program is not outputting what you expect - maybe it is adding some whitespace like newlines even though you told it not to - that would be another thing to check.

Replies are listed 'Best First'.
Re^2: Newbie doesn't understand Digest::MD5
by eltorio (Novice) on Apr 19, 2006 at 12:40 UTC
    Thanks for your help, I've just tried but binary mode doesn't change anything, but testing with string without @ charcter jhondoe:one_real:jhondoe gives a good result !
    echo -n "jhondoe:one_real:jhondoe" | perl computedigest.pl a20d2f25a66afc8db3befa1b4aca4d14 a20d2f25a66afc8db3befa1b4aca4d14
    Can it be a charcter issue? eltorio

      Yeouch - I didn't spot that error. You're running your code without use strict; and use warnings;, and either of them would have alerted you (and me) to what actually went wrong:

      Perl interpreted the @ondoe in your string as an array variable. That array variable isn't used and hence is empty. You need to use single quotes to prevent variable interpolation by Perl.

      Also, you should really start using warnings and strict, as they prevent typos from growing into hidden, hard to track down bugs.

        Thank you !!!! It works well. My error was double quote in place of simple quotes, starting now i'll always use
        use strict; use warnings;
        because it gives an explicit message.