def encode(char_data):
    """
    Encode the parameter as a byte string.

    :param char_data: the data to encode
    """
    if type(char_data) is str:
        return char_data.encode()
    elif type(char_data) is bytes:
        return char_data
    else:
        raise TypeError('message should be a string or bytes')
