Fw: MD5 in PHP and MD5 in Perl dont match up.
| From: | Steven Carr | Date: | Wed, 26 Mar 2003 16:23:33 +0000 |
| Subject: | Fw: MD5 in PHP and MD5 in Perl dont match up. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-141192@lists.php.net to get a copy of this message | ||
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.
The PHP is ..
$data = "Cheese";
print "Data: '$data' <P>\n";
$new_hash = md5($data);
print "RE HASH ' $new_hash ' <P>\n";
Output ....
Data: 'Cheese'
RE HASH ' a67778b3dcc82bfaace0f8bc0061f20e '
Thanks in advance,
Steve.
----- Original Message -----
From: "Steven Carr" <steven.carr@ish.de>
To: <php-general@lists.php.net>
Sent: Wednesday, March 26, 2003 4:20 PM
Subject: MD5 in PHP and MD5 in Perl dont match up.
>
> Hello All,
> Im having trouble with compatibility between MD5 Digest in Perl and in
> PHP. They dont give the same results.
>
> Perl....
>
> #!/usr/local/bin/perl
> use strict;
> use Digest::MD5 ();
>
> my $to_be_hashed = "Cheese";
> my ($hash) = Digest::MD5->md5_hex($to_be_hashed);
> print "to_be_hashed : '$to_be_hashed' <P>\n";
> print "hash : '$hash' <P>\n";
>
> Gives....
> to_be_hashed : 'Cheese' <P>
> hash : '0a2a1678f4189d19a08396d9af56b4bb' <P>
>
> In PHP..
> $data = "Cheese\n";
> print "Data: '$data' <P>\n";
> $new_hash = md5($data);
> print "RE HASH ' $new_hash ' <P>\n";
>
> Gives....
> Data: 'Cheese '
>
> RE HASH ' c69f543f8f2ab31d5b8f148f55b56c56 '
>
>
> I also tried a command line of echo -n 'Cheese' | md5sum
> Which gives me the same hash as Perl. PHP seems to give me different
> results.
>
> Any Ideas what I am doing wrong? Has anyone else experienced this?
>
>
> Many Thanks in advance,
>
> Steven Carr.
> ----------
> Steven Carr,
> ISP Engineering,
> steven.carr@ish.de
>