/** * 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; } }
public function testCheck() { list($hash, $salt) = TlonHash::password(self::GRUE_STRING); $this->assertTrue(TlonHash::check(self::GRUE_STRING, $hash, $salt)); }
/** * @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)); }