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,
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to