Verifies a password hash

@param   string  $password  The password to verify.
@param   string  $hash      The password hash to check.

@return  boolean  True if the password is valid, false otherwise.

@since   1.0
493709
public function verify($password, $hash)
	{
		// Check if the hash is a blowfish hash.
		if (substr($hash, 0, 4) == '$2a$' || substr($hash, 0, 4) == '$2y$')
		{
			if (version_compare(PHP_VERSION, '5.3.7') >= 0)
			{
				$type = '$2y$';
			}
			else
			{
				$type = '$2a$';
			}

			$hash = $type . substr($hash, 4);

			return (crypt($password, $hash) === $hash);
		}

		// Check if the hash is an MD5 hash.
		if (substr($hash, 0, 3) == '$1$')
		{
			return (crypt($password, $hash) === $hash);
		}

		// Check if the hash is a Joomla hash.
		if (preg_match('#[a-z0-9]{32}:[A-Za-z0-9]{32}#', $hash) === 1)
		{
			return md5($password . substr($hash, 33)) == substr($hash, 0, 32);
		}

		return false;
	}
328725
public function validatePassword(string $password): bool
    {
        $this->A1 = md5($this->digestParts['username'].':'.$this->realm.':'.$password);

        return $this->validate();
    }
61804
protected function validatePassword($password) {
        $state['error'] = true;

        if (strlen($password) < (int)$this->config->verify_password_min_length ) {
            $state['message'] = $this->__lang("password_short");

            return $state;
        }

        $state['error'] = false;

        return $state;
    }
943382
public static function verifyHash(string $hash, string $password): bool
    {
        /* Regenerating the with an available hash as the options parameter should
         * produce the same hash if the same password is passed.
         */
        return crypt($password, $hash) === $hash;
    }
739653
public function hash_password($password)
	{
		return base64_encode($this->hasher()->pbkdf2($password, \Config::get('auth.salt'), \Config::get('auth.iterations', 10000), 32));
	}
1125437
public function validatePassword(string $password): bool
    {
        return \Yii::$app->security->validatePassword($password, $this->password_hash);
    }
423127
public function checkPassword($password) {
    switch (Tilmeld::$config['pw_method']) {
      case 'plain':
        return ($this->password == $password);
      case 'digest':
        return ($this->password == hash('sha256', $password));
      case 'salt':
      default:
        return ($this->password == hash('sha256', $password.$this->salt));
    }
  }
1035222
public static function passwordCheck (string $password, string $existingHash) : bool
	{
		// Existing hash contains format and salt at start
		$hash = crypt($password, $existingHash);
		return ($hash == $existingHash) ? TRUE : FALSE;
	}
805051
public static function passwordReHash($password = '', $hash = '')
    {
        if (self::verifyPassword($password, $hash)) {
            if (password_needs_rehash($hash, self::ALGORITHM_DEFAULT)) {
                return self::createPassword($password);
            }
        }

        return NULL;
    }
794852
public function hash(string $password)
    {
        $algorithm = $this->config->dget('algorithm', PASSWORD_DEFAULT);
        $options['cost'] = $this->config->dget('cost', 10);

        return password_hash($password, $algorithm, $options);
    }
733780
public function hashExists($hash) 
    {
        $data = $this->getPasswordRequestData($hash);
        $h = '';
        foreach($data as $val) 
        {
            $h = $val->rh_login;
            //echo $h;
        }
        
        if(!empty($h)) {
            return true;
        }

        return false;   
    }
793982
public function hash(string $password): string
    {
        return Security::hash($password, $this->hashType, true);
    }
181011
public static function hashPassword($password)
    {
        # Test the message and key for string validity.
        Helpers::isString($password, 'Hash', 'hashPassword');

        return \Sodium\crypto_pwhash_scryptsalsa208sha256_str(
            $password,
            Constants::PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE,
            Constants::PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE
        );
    }
888056
public function verify(string $hash) : bool
    {
        if (is_null($this->rawValue)) {
            return false;
        }
        return password_verify($this->rawValue, $hash);
    }
448633
public static function verifyPassword($password, $passwordHash)
    {
        # Test the message and key for string validity.
        Helpers::isString($password, 'Hash', 'verifyPassword');
        Helpers::isString($passwordHash, 'Hash', 'verifyPassword');

        if (\Sodium\crypto_pwhash_scryptsalsa208sha256_str_verify($passwordHash, $password)) {
            \Sodium\memzero($password);

            return true;
        } else {
            \Sodium\memzero($password);

            return false;
        }
    }
844404
function passwordVerify($password, $hash) {
        if (!function_exists('crypt')) {
            trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
            return false;
        }
        $ret = crypt($password, $hash);
        if (!is_string($ret) || $this->_strlen($ret) != $this->_strlen($hash) || $this->_strlen($ret) <= 13) {
            return false;
        }

        $status = 0;
        for ($i = 0; $i < $this->_strlen($ret); $i++) {
            $status |= (ord($ret[$i]) ^ ord($hash[$i]));
        }

        return $status === 0;
    }
650634
public static function comparePasswordToHash( $plainText, $hash ) {
		if ( self::isBlowfishHash( $hash ) ) {
			$check = crypt( $plainText, $hash );

		} else {
			// horrible unsalted md5 that legacy app used for passwords
			$check = md5( $plainText );
		}

		return self::hashEquals( $hash, $check );
	}