Re: Fw: MD5 in PHP and MD5 in Perl dont match up.
| From: | Michael Sims | Date: | Thu, 27 Mar 2003 13:29:44 +0000 |
| Subject: | Re: Fw: MD5 in PHP and MD5 in Perl dont match up. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141213@lists.php.net to get a copy of this message | ||
On Wed, 26 Mar 2003 17:23:33 +0100, you wrote:
>Im Very Sorry / Embarrased.. my code example had a mistake with extra
>linebreak. Here is the example with out it, which gives a different MD5
>hash.
I don't know why this is, but if you call Digest::MD5->md5_hex() in a
procedural rather than OO way, it works. I changed your perl to the
following:
#!/usr/local/bin/perl
use strict;
use Digest::MD5 qw(md5_hex);
my $to_be_hashed = "Cheese";
#my ($hash) = Digest::MD5->md5_hex($to_be_hashed);
my ($hash) = md5_hex($to_be_hashed);
print "to_be_hashed : '$to_be_hashed' <P>\n";
print "hash : '$hash' <P>\n";
And now it prints the same digest that the PHP version does:
to_be_hashed : 'Cheese' <P>
hash : 'a67778b3dcc82bfaace0f8bc0061f20e' <P>
HTH...