From:             tom at tdwright dot co dot uk
Operating system: Linux + Windows
PHP version:      5.2.6
PHP Bug Type:     Feature/Change Request
Bug description:  MD5 should use utf8 to be comparable with non-php hashes

Description:
------------
It seems that the MD5 function in php uses the UTF7 encoding of a string
for the algorithm. Every other implementation seems to use UTF8.
Finding out about this discrepancy was not easy as
a) The programming community at large presumably takes it for granted that
MD5 uses a UTF8 encoded string
b) PHP programmers don't often need to compare their PHP generated hashes
with those generated outside of PHP.
It's a really annoying quirk and I'd love to see a change (even if it's an
option).

Reproduce code:
---------------
<?php
$hash_from_another_lang = $_POST['hash1'];
$php_hash = md5("hashtext");
return ($hash_from_another_lang == $php_hash);
?>

Expected result:
----------------
true

MD5 hashes should match wherever they are generated.

Actual result:
--------------
false

The PHP implementation of the MD5 algorithm produces hashes which are
incongruent with the results of any other (AFAIK) MD5 implementation. 

-- 
Edit bug report at http://bugs.php.net/?id=45650&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45650&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45650&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45650&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45650&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45650&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45650&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45650&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45650&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45650&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45650&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45650&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45650&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45650&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45650&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45650&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45650&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45650&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45650&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45650&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45650&r=mysqlcfg

Reply via email to