I'm trying to compare an MD5 checksum generated by PHP to one generated by Oracle 10g. However it seems I'm comparing apples to oranges.
Here's what I did to test the comparison:
//md5 tests
  //php md5
  print md5('testingthemd5function');
  print '<br/><br/>';
  //oracle md5
  $md5query = "select md5hash('testingthemd5function') from dual";
  $stid = oci_parse($conn, $md5query);
  if (!$stid) {
   $e = oci_error($conn);
   print htmlentities($e['message']);
   exit;
  }
  $r = oci_execute($stid, OCI_DEFAULT);
  if (!$r) {
   $e = oci_error($stid);
   echo htmlentities($e['message']);
   exit;
  }
  $row = oci_fetch_row($stid); 
  print $row[0];
The md5 function (seen in the query above) in Oracle uses the 'dbms_obfuscation_toolkit.md5' package(?) and is defined like this:
CREATE OR REPLACE FUNCTION PORTAL.md5hash (v_input_string in varchar2) return varchar2     
is
   v_checksum varchar2(20);
   begin
   v_checksum := dbms_obfuscation_toolkit.md5 (input_string => v_input_string);
   return v_checksum;
end;
What comes out on my PHP page is:
29dbb90ea99a397b946518c84f45e016
)Û¹©š9{”eÈOEà 
Can anyone help me in getting the two to match?
It returns raw bytes, you need to convert that into hex.
$x = unpack("H*", $row[0]); 
echo $x[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With