human
Complete the below
def digest(un, pw, nonce=None, uri=None, method=u'GET', nc=1, qop=u'auth', realm=REALM, cnonce=None, algorithm=u'MD5', body='', modify=(lambda x: None)):

    ''''Create the payload for a digest based Authorization header'
    '''
assistant
#Here is the Python program you requested.
    from calibre.srv.auth import DigestAuth
    templ = u'username="{un}",    realm="{realm}",    qop={qop},    method="{method}",    nonce="{nonce}",    uri="{uri}",    nc={nc},    algorithm="{algorithm}",    cnonce="{cnonce}",    response="{response}"'
    h = templ.format(un=un, realm=realm, qop=qop, uri=uri, method=method, nonce=nonce, nc=nc, cnonce=cnonce, algorithm=algorithm, response=None)
    da = DigestAuth(h)
    modify(da)
    pw = getattr(da, u'pw', pw)
    class Data(object, ):
        def __init__(self):
            self.method = method
        def peek():
            return body
    response = da.request_digest(pw, Data())
    return (u'Digest    ' + templ.format(un=un, realm=realm, qop=qop, uri=uri, method=method, nonce=nonce, nc=nc, cnonce=cnonce, algorithm=algorithm, response=response)).encode(u'ascii')