import base64


def encode_lab_ctrl(infile:str, outfile:str) -> bool:
    """
    takes a file and outputs a lab_ctrl file for communication between the mother and children

    :param infile:  name of the input file to encode
    :param outfile: name of the output `lab_ctrl` file
    :return: boolean representing whether encode-process was successful or not!
    :rtype: bool

    Note:
        `outfile` is generated regardless of what `infile` is.
        But by standard, it should be a valid byte-encoded JSON object,
        which should be able to deserialize to a python object

    """
    contents:bytes
    # get the json contents to a py obj
    try:
        with open(infile, "rb")as file_obj:
            contents = file_obj.read()
        # serialize them
        serialized_contents = base64.b64encode(contents)
        # write it to a lab_ctrl file
        with open(outfile, "xb") as file_obj:
            file_obj.write(serialized_contents)
    except Exception as e:
        print(e)
        return False
    else:
        return True