Check string against hashed string.

@param  string  $string
@param  string  $hashedString
@return bool
347426
public function checkhash($string, $hashedString)
	{
		$verified = password_verify($string, $hashedString);
		if ( ! $verified) 
		{
			// Try the fallbacks
			foreach (static::$fallbacks as $algo => $fallback)
			{
				$verified = $fallback['function']($string, $hashedString, $fallback['options']);
				if ($verified) break;
			}
		}
		return $verified;
	}
802740
public static function startsWith($string, $substrings)
    {
        if (is_array($substrings)) {
            foreach ((array) $substrings as $substring) {
                if ($substring != '' && mb_strpos($string, $substring) === 0) {
                    return true;
                }
            }
        } elseif (is_string($substrings)) {
            if ($substrings != '' && mb_strpos($string, $substrings) === 0) {
                return true;
            }
        }

        return false;
    }
272687
public static function isClass($string)
    {
        if (is_string($string) === true) {
            $pattern = "/^(?:[^\s]+?(?:\x20){0,})+$/";
    
            return preg_match($pattern, $string) === 1;
        } else {
            
            return false;
        }
    }
463830
public static function contains($string = false, $substring = false) {

        if ($substring && $substring && strpos($string, $substring) !== false) {

            return true;
        }

        return false;
    }
751010
public static function verify($string, $hash, array $arguments = [])
    {
        return self::instance()->{__FUNCTION__}($string, $hash, $arguments);
    }
917185
public static function check(string $data, string $hash, string $method='SHA256'): bool
  {
    $hash_compare = \openssl_digest($data,$method);

    return (\strcmp($hash, $hash_compare) === 0);
  }
74471
public static function validateTrimmed($string)
    {
        if (SetupHelper::trim($string) === $string) {
            return (string)$string;
        }

        throw new InvalidArgumentException(
            sprintf(
                'Provided string "%1$s" was not trimmed.',
                $string
            )
        );
    }
38036
function hashString(string) {
  // This is the hash from JVM
  // The hash code for a string is computed as
  // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  // where s[i] is the ith character of the string and n is the length of
  // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  // (exclusive) by dropping high bits.
  let hashed = 0;
  for (let ii = 0; ii < string.length; ii++) {
    hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  }
  return smi(hashed);
}
991591
public function hash($string, $algo)
    {
        if (true === empty($string)) {
            $string = microtime() . uniqid();
        }

        return hash($algo, $string);
    }
594571
public static function hashString($string, $iteration = 5)
    {
        $result = $string;

        for ($i = 0; $i < $iteration; $i++) {
            $result = md5($result);
        }

        return $result;
    }
161163
public static function hashEquals($known_string, $user_string) {
    if (function_exists('hash_equals')) {
      return hash_equals($known_string, $user_string);
    }
    else {
      // Backport of hash_equals() function from PHP 5.6
      // @see https://github.com/php/php-src/blob/PHP-5.6/ext/hash/hash.c#L739
      if (!is_string($known_string)) {
        trigger_error(sprintf("Expected known_string to be a string, %s given", gettype($known_string)), E_USER_WARNING);
        return FALSE;
      }

      if (!is_string($user_string)) {
        trigger_error(sprintf("Expected user_string to be a string, %s given", gettype($user_string)), E_USER_WARNING);
        return FALSE;
      }

      $known_len = strlen($known_string);
      if ($known_len !== strlen($user_string)) {
        return FALSE;
      }

      // This is security sensitive code. Do not optimize this for speed.
      $result = 0;
      for ($i = 0; $i < $known_len; $i++) {
        $result |= (ord($known_string[$i]) ^ ord($user_string[$i]));
      }

      return $result === 0;
    }
  }
1288880
public static function verify($string, $hash)
    {
        $pattern = '~^'.preg_quote(self::PREFIX).'(?<salt>[A-Za-z0-9\./]{8})\$(?<sub>[A-Za-z0-9\./]+)$~is';
        if (!preg_match($pattern, $hash, $matches)) {
            return false;
        }
        return ($matches['sub'] === self::createSubHash($string, $matches['salt']));
    }
410626
private function compareStrings($knownString, $userString)
    {
        $result = "\x00";

        for ($i = 0, $length = strlen($knownString); $i < $length; $i++) {
            $result |= $knownString[$i] ^ $userString[$i];
        }

        return $result === "\x00";
    }
1323228
public static function isLength($string = false, $minLength = 0, $maxLength = false) {

        if ($string && strlen($string) >= $minLength) {

            if (!$maxLength || strlen($string) <= $maxLength) {

                return true;
            }
        }

        return false;
    }
635481
public static function simpleHash($string): ?string
    {
        if (!Any::isLine($string)) {
            return null;
        }

        return dechex(crc32($string));
    }
353949
public function startsWith(string $string) : bool
    {
        return substr($this->path, 0, strlen($string)) === $string;
    }
626136
public function hash($string)
	{
		// Usually caused by an old PHP environment, see
		// https://github.com/cartalyst/sentry/issues/98#issuecomment-12974603
		// and https://github.com/ircmaxell/password_compat/issues/10
		if ( ! function_exists('password_hash'))
		{
			throw new \RuntimeException('The function password_hash() does not exist, your PHP environment is probably incompatible. Try running [vendor/ircmaxell/password-compat/version-test.php] to check compatibility or use an alternative hashing strategy.');
		}

		if (($hash = password_hash($string, PASSWORD_DEFAULT)) === false)
		{
			throw new \RuntimeException('Error generating hash from string, your PHP environment is probably incompatible. Try running [vendor/ircmaxell/password-compat/version-test.php] to check compatibility or use an alternative hashing strategy.');
		}

		return $hash;
	}