Equivalent to hash_equals() in PHP 5.6

@param string $knownString
@param string $userString

@return bool
163104
public static function hashEquals($knownString, $userString)
    {
        // We have to roll our own
        $kLen = self::ourStrlen($knownString);
        $uLen = self::ourStrlen($userString);
        if ($kLen !== $uLen) {
            return false;
        }
        $result = 0;
        for ($i = 0; $i < $kLen; $i++) {
            $result |= (ord($knownString[$i]) ^ ord($userString[$i]));
        }
        // They are only identical strings if $result is exactly 0...
        return 0 === $result;
    }
908290
public static function endsWith($string, $substrings)
    {
        if (is_array($substrings)) {
            foreach ((array) $substrings as $substring) {
                if ((string) $substring === static::subString($string, -static::length($substring))) {
                    return true;
                }
            }
        } elseif (is_string($substrings)) {
            if ((string) $substring === static::subString($string, -static::length($substring))) {
                return true;
            }
        }

        return false;
    }
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";
    }
635481
public static function simpleHash($string): ?string
    {
        if (!Any::isLine($string)) {
            return null;
        }

        return dechex(crc32($string));
    }
897367
public static function hash($string)
    {
        $salt = self::createSalt();
        return self::PREFIX.$salt.'$'.self::createSubHash($string, $salt);
    }
751010
public static function verify($string, $hash, array $arguments = [])
    {
        return self::instance()->{__FUNCTION__}($string, $hash, $arguments);
    }
554553
public function hasSubstring( $pSubstring ) {
        if ( strlen( $pSubstring ) < 1 ) {
            return -1;
        }

        return $this->findSubstring( $this->nodes[$this->root], $pSubstring );
    }
594571
public static function hashString($string, $iteration = 5)
    {
        $result = $string;

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

        return $result;
    }
182025
def search(self, searchstring):
        
        ret = {}
        for user in self.users:
            match = False
            for attr in self.search_attrs:
                if attr not in self.users[user]:
                    pass
                elif re.search(searchstring + '.*', self.users[user][attr]):
                    match = True
            if match:
                ret[user] = self.users[user]
        return ret
1284864
public function hash(string $string): Hash {
        $hash = new Hash();
        $hash->setAlgorithm($this->getAlgorithm());
        $value = hash($this->getAlgorithm(), $string, true);
        $hash->setValue($value);
        return $hash;
    }
524472
public function equalsIgnoreCase($string): bool
    {
        try {
            Assert::typeOf(['string', __CLASS__], $string);
        } catch (InvalidArgumentException|TypeError $t) {
            return false;
        }

        return strcmp(
            mb_strtolower($this->data, $this->encoding),
            mb_strtolower((string) $string, $this->encoding)
        ) === 0;
    }
886620
public function hashEquals($expected, $generated)
    {
        $expectedLength = strlen($expected);

        if ($expectedLength !== strlen($generated)) {
            return false;
        }

        $res = 0;

        for ($i = 0; $i < $expectedLength; ++$i) {
            $res |= ord($expected[$i]) ^ ord($generated[$i]);
        }

        return $res === 0;
    }
424665
public static function verifyHMAC(string $hash, string $text, string $salt, string $format = null): bool
    {
        return \hash_equals($hash, self::hmac($text, $salt, $format));
    }
953479
public function hash($string, $key = null)
    {

        $publicKey = is_null($key) ? $this->generateKey($string) : $key;

        //echo $publicKey;
        $hashKey1 = sha1($string . $publicKey);
        $hashKey2 = md5($hashKey1);
        $hashKey3 = hash('sha224', $hashKey2);

        return $hashKey3 . ":" . $publicKey;
    }
1089092
public function setUNA(string $chars, bool $user_call = true): bool
    {
        if (\is_string($chars)
            && \strlen($chars) == 6
        ) {
            $this->sepComp = $chars[0];
            $this->sepData = $chars[1];
            $this->sepDec = $chars[2];
            $this->symbRel = $chars[3];
            $this->symbRep = $chars[4];
            $this->symbEnd = $chars[5];

            if ($user_call) {
                $this->enableUNA();
            }

            if ($this->output != '') {
                $this->output = $this->encode($this->originalArray);
            }

            return true;
        }

        return false;
    }
618762
protected function _stringHasR($str) {
		foreach (func_get_args() as $arg) {
			if (strpos($arg, "\r") !== false) {
				return true;
			}
		}
		return false;
	}
1034521
function hash($string) {
		$options = [];
		if (!is_null($this->cost))
			$options	= ['cost'	=> $this->cost];
		
		return password_hash($string, PASSWORD_DEFAULT, $options);
	}