Cartalyst\Sentinel\Hashing\Hasher::slowEquals PHP Method

slowEquals() protected method

Compares two strings $a and $b in length-constant time.
protected slowEquals ( string $a, string $b ) : boolean
$a string
$b string
return boolean
    protected function slowEquals($a, $b)
    {
        $diff = strlen($a) ^ strlen($b);
        for ($i = 0; $i < strlen($a) && $i < strlen($b); $i++) {
            $diff |= ord($a[$i]) ^ ord($b[$i]);
        }
        return $diff === 0;
    }