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)):
 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')

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 ) ) : 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' )
return a checksum digest for a string instr a string checksum : md5 the hashing algorithm to use to generate checksums .