Ejemplo n.º 1
0
 /**
  * Sets a user's password.
  * 
  * @param string $password 	The new password to set
  * @return boolean 			Always true
  */
 public function setPassword($password)
 {
     sfCore::$db->query("UPDATE `swoosh_users` SET `password`=%s WHERE `id`=%i", sfBcrypt::hash($password), $this->id);
     return true;
 }
Ejemplo n.º 2
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.º 3
0
 /**
  * Set a work factor to use for hashing in this session. This only affects hash(), as
  * check() will automatically parse the hash and use the correct work factor.
  * 
  * @param integer $work_factor 	The work factor to use
  */
 public static function set_work_factor($work_factor)
 {
     self::$work_factor = $work_factor;
 }