Ejemplo n.º 1
0
<?php

require 'sfCore.php';
$pass = '******';
echo 'Comparison (sha1): <br />';
$time_start = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $hash = sha1($pass);
}
$duration = microtime(true) - $time_start;
echo 'SHA 1 Hash: ' . $hash . " (took {$duration} seconds)<br /><br />";
echo 'Hashing password ' . $pass . ':<br />';
flush();
$time_start = microtime(true);
$hash = sfBcrypt::hash($pass, 13);
$duration = microtime(true) - $time_start;
echo 'Hash: ' . $hash . " (took {$duration} seconds)<br /><br />";
echo "Checking hash... ";
flush();
$time_start = microtime(true);
if (sfBcrypt::check($pass, $hash)) {
    $duration = microtime(true) - $time_start;
    echo "OK (took {$duration} seconds)";
} else {
    $duration = microtime(true) - $time_start;
    echo "FAIL (took {$duration} seconds)";
}
Ejemplo n.º 2
0
 /**
  * Matches a given password with the one stored for this user.
  * 
  * @param string $passowrd	The password to match against
  * @return boolean 			If the password matches the user
  */
 public function matchPassword($password)
 {
     $this->loadPrivateData();
     return sfBcrypt::check($password, $this->password);
 }