Psecio\Jwt\Jwt::hash_equals PHP Method

hash_equals() public method

Polyfill PHP 5.6.0's hash_equals() feature
public hash_equals ( $a, $b )
    public function hash_equals($a, $b)
    {
        if (\function_exists('hash_equals')) {
            return \hash_equals($a, $b);
        }
        if (\strlen($a) !== \strlen($b)) {
            return false;
        }
        $res = 0;
        $len = \strlen($a);
        for ($i = 0; $i < $len; ++$i) {
            $res |= \ord($a[$i]) ^ \ord($b[$i]);
        }
        return $res === 0;
    }