Example #1
0
 /**
  * add(): Make a new nonce, insert in the TABLE, and return it.
  * @return string  New nonce, or false if add failed.
  */
 public static function add()
 {
     self::clean();
     $nonce = TlonHash::hash(TlonHash::salt(), $_SERVER['REMOTE_ADDR']);
     if (TlonData::insert(self::$TABLE, array($nonce, time()))) {
         return $nonce;
     } else {
         return false;
     }
 }
Example #2
0
 public function testCheck()
 {
     list($hash, $salt) = TlonHash::password(self::GRUE_STRING);
     $this->assertTrue(TlonHash::check(self::GRUE_STRING, $hash, $salt));
 }
Example #3
0
 /**
  * @param string $username User name.
  * @param string $password Password.
  * @return bool  Success or failure.
  */
 public static function updatePassword($username, $password)
 {
     list($hash, $salt) = TlonHash::password($password);
     return self::update(self::$TABLE, array(TlonDataComparison::set('password', $hash), TlonDataComparison::set('salt', $salt)), TlonDataComparison::equals('username', $username));
 }