'Calculates response with given encoded parameters.
@return: The I{response} field of a response to a Digest-MD5 challenge
of the given parameters.
@rtype: L{bytes}'

def _calculateResponse(self, cnonce, nc, nonce, username, password, realm, uri):

    def H(s):
        return md5(s).digest()
    def HEX(n):
        return binascii.b2a_hex(n)
    def KD(k, s):
        return H(((k + ':') + s))
    a1 = ((((H(((((username + ':') + realm) + ':') + password)) + ':') + nonce) + ':') + cnonce)
    a2 = ('AUTHENTICATE:' + uri)
    response = HEX(KD(HEX(H(a1)), ((((((((nonce + ':') + nc) + ':') + cnonce) + ':') + 'auth') + ':') + HEX(H(a2)))))
    return response
