<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_digest( self, realm, nonce, qop=("auth",), opaque=None, algorithm=None, stale=False ):
 """Clear the auth info and enable digest auth."""

        d = {
            "__auth_type__": "digest",
            "realm": realm,
            "nonce": nonce,
            "qop": dump_header(qop),
        }
        if stale:
            d["stale"] = "TRUE"
        if opaque is not None:
            d["opaque"] = opaque
        if algorithm is not None:
            d["algorithm"] = algorithm
        dict.clear(self)
        dict.update(self, d)
        if self.on_update:
            self.on_update(self)