Doc #61307 [Opn->Csd]: hash-tiger generates a different value between 5.3/5.4

From: Date: Sun, 14 Jun 2015 15:01:18 +0000
Subject: Doc #61307 [Opn->Csd]: hash-tiger generates a different value between 5.3/5.4
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12420@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61307&edit=1 ID: 61307 Updated by: cmb@php.net Reported by: andres at phalconphp dot com Summary: hash-tiger generates a different value between 5.3/5.4 -Status: Open +Status: Closed Type: Documentation Problem Package: hash related Operating System: Irrelevant PHP Version: 5.4.0 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2015-06-14 15:00:40] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=336947 Log: added example regarding changed byte-order of tiger hashes as of PHP 5.4 (fixes #61307) ------------------------------------------------------------------------ [2012-03-09 08:51:26] mike@php.net The doc team would probably not notice an "not a bug" bug ;) ------------------------------------------------------------------------ [2012-03-09 08:49:50] mike@php.net Here's something for the documentation team: /* calculate pre-php-5.4 tiger hashes with php-5.4 */ function old_tiger($data = "", $width=192, $rounds = 3) { return substr( implode( array_map( function ($h) { return str_pad(bin2hex(strrev($h)), 16, "0"); }, str_split(hash("tiger192,$rounds", $data, true), 8) ) ), 0, 48-(192-$width)/4 ); } ------------------------------------------------------------------------ [2012-03-08 21:16:04] andres at phalconphp dot com Thanks Mike and Rasmus for all your great help! ------------------------------------------------------------------------ [2012-03-08 17:26:48] mike@php.net Sorry folks, here's a one-liner to re-create pre-PHP-5.4 hashes: implode("", array_map("bin2hex", array_map("strrev", str_split(hash("tiger192,3", $input, true), 8)))); Truncate the result to the length you need (128,160,192 bits). Make sure every array value is 16 hex digits long or else lpad it with literal 0s. If you used 192 bit tiger, you can use the following one-liner to create correct hashes from the wrong ones: implode("", array_map("bin2hex", array_map("strrev", array_map("hex2bin", str_split($wronghash,16))))); ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=61307 -- Edit this bug report at https://bugs.php.net/bug.php?id=61307&edit=1

« previous php.doc.bugs (#12420) next »