Getting Oracle's MD5 to match PHP's MD5
Posted
by Zenshai
on Stack Overflow
See other posts from Stack Overflow
or by Zenshai
Published on 2009-08-04T16:56:11Z
Indexed on
2010/04/16
10:43 UTC
Read the original article
Hit count: 695
Hi all,
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?
© Stack Overflow or respective owner