def HA2(credentails, request, algorithm):
 if ((credentails.get('qop') == 'auth') or (credentails.get('qop') is None)):
  return H(':'.join([request['method'].encode('utf-8'), request['uri'].encode('utf-8')]), algorithm)
 elif (credentails.get('qop') == 'auth-int'):
  for k in ('method', 'uri', 'body'):
   if (k not in request):
    raise ValueError(('%s required' % k))
  A2 = ':'.join([request['method'].encode('utf-8'), request['uri'].encode('utf-8'), H(request['body'], algorithm).encode('utf-8')])
  return H(A2, algorithm)
 raise ValueError

def HA2 ( credentails , request , algorithm ) : if ( ( credentails . get ( 'qop' ) == 'auth' ) or ( credentails . get ( 'qop' ) is None ) ) : return H ( ':' . join ( [ request [ 'method' ] . encode ( 'utf-8' ) , request [ 'uri' ] . encode ( 'utf-8' ) ] ) , algorithm ) elif ( credentails . get ( 'qop' ) == 'auth-int' ) : for k in ( 'method' , 'uri' , 'body' ) : if ( k not in request ) : raise ValueError ( ( '%s required' % k ) ) A2 = ':' . join ( [ request [ 'method' ] . encode ( 'utf-8' ) , request [ 'uri' ] . encode ( 'utf-8' ) , H ( request [ 'body' ] , algorithm ) . encode ( 'utf-8' ) ] ) return H ( A2 , algorithm ) raise ValueError
create ha2 md5 hash if the qop directives value is "auth" or is unspecified .