svn: /phpdoc/en/trunk/reference/hash/functions/ hash.xml

From: Date: Sun, 14 Jun 2015 15:00:38 +0000
Subject: svn: /phpdoc/en/trunk/reference/hash/functions/ hash.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13396@lists.php.net to get a copy of this message
cmb Sun, 14 Jun 2015 15:00:38 +0000 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) Bug: https://bugs.php.net/61307 (Open) hash-tiger generates a different value between 5.3/5.4 Changed paths: U phpdoc/en/trunk/reference/hash/functions/hash.xml Modified: phpdoc/en/trunk/reference/hash/functions/hash.xml =================================================================== --- phpdoc/en/trunk/reference/hash/functions/hash.xml 2015-06-14 14:35:52 UTC (rev 336946) +++ phpdoc/en/trunk/reference/hash/functions/hash.xml 2015-06-14 15:00:38 UTC (rev 336947) @@ -71,7 +71,7 @@ <tbody> <row> <entry>5.4.0</entry> - <entry>The tiger algorithm now uses big-endian byte ordering.</entry> + <entry>The tiger algorithm now uses big-endian byte ordering. See also example below.</entry> </row> </tbody> </tgroup> @@ -99,6 +99,46 @@ </screen> </example> </para> + <para> + <example> + <title>Calculate pre PHP-5.4 tiger hashes with PHP-5.4 and higher</title> + <programlisting role="php"> +<![CDATA[ +<?php +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 + ); +} +echo hash('tiger192,3', 'a-string'), PHP_EOL; +echo old_tiger('a-string'), PHP_EOL; +?> +]]> + </programlisting> + &example.outputs.53; + <screen> +<![CDATA[ +146a7492719b3564094efe7abbd40a7416fd900179d02773 +64359b7192746a14740ad4bb7afe4e097327d0790190fd16 +]]> + </screen> + &example.outputs.54; + <screen> +<![CDATA[ +64359b7192746a14740ad4bb7afe4e097327d0790190fd16 +146a7492719b3564094efe7abbd40a7416fd900179d02773 +]]> + </screen> + </example> + </para> </refsect1> <refsect1 role="seealso">

« previous php.doc.cvs (#13396) next »