I\'m essentially preparing phrases to be put into the database, they may be malformed so I want to store a short hash of them instead (I will be simply comparing if they exi
The implementation for md5 inside hash is a little bit faster than md5(). So this can be an option or some else, please try:
echo '<pre>';
$run = array();
function test($algo)
{
#static $c = 0;
#if($c>10) return;
#$c++;
$tss = microtime(true);
for($i=0; $i<100000; $i++){
$x = hash($algo, "ana are mere");
}
$tse = microtime(true);
$GLOBALS['run'][(string)round($tse-$tss, 5)] = "\nhash({$algo}): \t".round($tse-$tss, 5) . " \t" . $x;
#echo "\n$i nhash({$algo}): \t".round($tse-$tss, 5) . " \t" . $x;
}
array_map('test', hash_algos());
ksort($run);
print_r($run);
echo '</pre>';
You can see at http://www.dozent.net/Tipps-Tricks/PHP/hash-performance