def _computeDigestResponse(auth_map, password, method='GET', A1=None, **kwargs):
 params = auth_map
 algorithm = params.get('algorithm', MD5)
 H = DIGEST_AUTH_ENCODERS[algorithm]
 KD = (lambda secret, data: H(((secret + ':') + data)))
 qop = params.get('qop', None)
 H_A2 = H(_A2(params, method, kwargs))
 if ((algorithm == MD5_SESS) and (A1 is not None)):
  H_A1 = H(A1)
 else:
  H_A1 = H(_A1(params, password))
 if (qop in ('auth', 'auth-int')):
  request = ('%s:%s:%s:%s:%s' % (params['nonce'], params['nc'], params['cnonce'], params['qop'], H_A2))
 elif (qop is None):
  request = ('%s:%s' % (params['nonce'], H_A2))
 return KD(H_A1, request)

def _computeDigestResponse ( auth_map , password , method = 'GET' , A1 = None , ** kwargs ) : params = auth_map algorithm = params . get ( 'algorithm' , MD5 ) H = DIGEST_AUTH_ENCODERS [ algorithm ] KD = ( lambda secret , data : H ( ( ( secret + ':' ) + data ) ) ) qop = params . get ( 'qop' , None ) H_A2 = H ( _A2 ( params , method , kwargs ) ) if ( ( algorithm == MD5_SESS ) and ( A1 is not None ) ) : H_A1 = H ( A1 ) else : H_A1 = H ( _A1 ( params , password ) ) if ( qop in ( 'auth' , 'auth-int' ) ) : request = ( '%s:%s:%s:%s:%s' % ( params [ 'nonce' ] , params [ 'nc' ] , params [ 'cnonce' ] , params [ 'qop' ] , H_A2 ) ) elif ( qop is None ) : request = ( '%s:%s' % ( params [ 'nonce' ] , H_A2 ) ) return KD ( H_A1 , request )
generates a response respecting the algorithm defined in rfc 2617 .