暗号化にかかる時間の比較
693 ワード
<?php
define('testtime', 50000);
$a=mcrypt_list_algorithms();
$b=mcrypt_list_modes();
var_dump($a,$b);
$algos = hash_algos();
foreach($algos as $algo) {
$st = microtime();
for($i = 0; $i < testtime; $i++) {
hash($algo, microtime().$i);
}
$et = microtime();
list($ss, $si) = explode(' ', $st);
list($es, $ei) = explode(' ', $et);
$time[$algo] = $ei + $es - $si - $ss;
}
asort($time, SORT_NUMERIC);
var_dump($time);
$data = "hello";
foreach (hash_algos() as $v) {
$r = hash($v, $data, false);
printf("%-12s %3d %s\r
<br>", $v, strlen($r), $r);
}
?>