<?php
class HashCracker
{
private $range = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
private $length = 32;
private $cycles = 1000;
public function runBenchmark($hash, $prefix = '')
{
foreach ($this->range as $key) {
$match = $prefix . $key;
$times[$match] = microtime(true);
for ($i = 0; $i < $this->cycles; $i += 1) {
strcmp($hash, $match);
}
$times[$match] = microtime(true) - $times[$match];
}
asort($times);
var_dump($times, reset($times));
}
}
$password = 'hello';
$hashed = md5($password);
var_dump('Hash to match: ' . $hashed);
(new HashCracker())->runBenchmark($hashed);
preferences:
32.87 ms | 402 KiB | 5 Q