# Path: roscraco/exception.py
# class RouterError(Exception):
#     pass


import re
from ..exception import RouterError
    from .converter import ip2long
        return False
    except KeyError:
        raise RouterError('Invalid bit length: %d' % int(bit_length))


def is_wep_password_in_hex(password, bit_length):
    """Tells whether we're using HEX or ASCII for the specified password."""
    if password is None:
        return False
    # the password could be either HEX or ASCII
    # HEX is valid ASCII too
    try:
        password = password.decode('ascii')
    except (UnicodeDecodeError, UnicodeEncodeError):
        raise RouterError('Cannot validate password as HEX or ASCII: %s' %
                          password)

    length = len(password)

    try:
        constraints = WEP_CONSTRAINTS_MAP[bit_length]

        if length == constraints['ascii']:
            return False
        elif length == constraints['hex']:
            # if the string is that long, it can only be in HEX
            return _is_hex_string(password)

        return False
    except KeyError:

# Path: roscraco/exception.py
# class RouterError(Exception):
#     pass


# Path: roscraco/helper/validator.py
import re
from ..exception import RouterError
    from .converter import ip2long

        return False
    except KeyError:
        raise RouterError('Invalid bit length: %d' % int(bit_length))


def is_wep_password_in_hex(password, bit_length):
    """Tells whether we're using HEX or ASCII for the specified password."""
    if password is None:
        return False
    # the password could be either HEX or ASCII
    # HEX is valid ASCII too
    try:
        password = password.decode('ascii')
    except (UnicodeDecodeError, UnicodeEncodeError):
        raise RouterError('Cannot validate password as HEX or ASCII: %s' %
                          password)

    length = len(password)

    try:
        constraints = WEP_CONSTRAINTS_MAP[bit_length]

        if length == constraints['ascii']:
            return False
        elif length == constraints['hex']:
            # if the string is that long, it can only be in HEX
            return _is_hex_string(password)

        return False
    except KeyError:

        raise RouterError('Invalid bit length: %d' % int(bit_length))