private static function hash_equals($expected, $actual) {

        $expected = (string) $expected;
        $actual   = (string) $actual;
        
        if(true === function_exists('hash_equals')) {
            return hash_equals($expected, $actual);
        }

        $lenExpected  = mb_strlen($expected, self :: ENCODING);
        $lenActual    = mb_strlen($actual, self :: ENCODING);
        $len          = min($lenExpected, $lenActual);
        $result       = 0;
        
        for ($i = 0; $i < $len; $i++) {
            $result |= ord($expected[$i]) ^ ord($actual[$i]);
        }

        $result |= $lenExpected ^ $lenActual;

        return ($result === 0);
    }