<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_id(cls, prefix="pelix-"):
 """ Generates a random MQTT client ID :param prefix: Client ID prefix (truncated to 8 chars) :return: A client ID of 22 or 23 characters """

        if not prefix:
            # Normalize string
            prefix = ""
        else:
            # Truncate long prefixes
            prefix = prefix[:8]

        # Prepare the missing part
        nb_bytes = (23 - len(prefix)) // 2

        random_bytes = os.urandom(nb_bytes)
        if sys.version_info[0] >= 3:
            random_ints = [char for char in random_bytes]
        else:
            random_ints = [ord(char) for char in random_bytes]

        random_id = "".join("{0:02x}".format(value) for value in random_ints)
        return "{0}{1}".format(prefix, random_id)