def parse_authorization_header(value, charset='utf-8'):
    '''Parse an HTTP basic/digest authorisation header.

    :param value: the authorisation header to parse.
    :return: either `None` if the header was invalid or
        not given, otherwise an :class:`Auth` object.
    '''
    if not value:
        return
    try:
        auth_type, auth_info = value.split(None, 1)
        auth_type = auth_type.lower()
    except __HOLE__:
        return
    if auth_type == 'basic':
        try:
            up = b64decode(auth_info.encode(DEFAULT_CHARSET)).decode(charset)
            username, password = up.split(':', 1)
        except Exception:
            return
        return BasicAuth(username, password)
    elif auth_type == 'digest':
        auth_map = parse_dict_header(auth_info)
        if not digest_parameters.difference(auth_map):
            return DigestAuth(auth_map.pop('username'), options=auth_map)
dataset/ETHPy150Open quantmind/pulsar/pulsar/apps/wsgi/auth.py/parse_authorization_header