Calculate hash from value (must be bytes).

def hash(self, val):
        """Calculate hash from value (must be bytes)."""

        if not isinstance(val, bytes):
            raise _TypeError("val", "bytes", val)

        rv = self.compute(val)

        if not isinstance(val, bytes):
            raise _TypeError("val", "bytes", rv)

        return rv