Esempio n. 1
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

        text = "En ces créations esthétiques d'une nature nouvelle, la "\
            "perception du «texte» se transforme en effet. Certes, lorsqu'on "\
            "consulte un numéro de la revue alire, ce qui est d'abord "\
            "«affiché» sur un écran d'ordinateur et qui est ensuite «vu», "\
            "puis «lu» et «interprété» comme étant un «texte poétique» "\
            "demeure agencé en des mots, des lettres ou des énoncés dont "\
            "l'entrelacs constitue le «tissu» de significations d'où "\
            "sourdent des émotions et des réflexions."
        ui.message("--- Hiding ---")
        data = "Hacker"
        ui.message("Text used as source (input file): {}".format(text))
        ui.message("Data to hide: {}\n".format(data))
        ui.message("Text with hidden data (output file): {}"
                   "".format(spaces.hide(text, data)))
        ui.message("")

        ui.message("--- Unhiding ---")
        htext = "'La vitalité de  la création  littéraire par ordinateur  a"\
            "  été réaffirmée  en  ce début du XXIe siècle,  à Paris,  au  "\
            "Salon du  livre,  avec la parution le  21  mars  2000 du  "\
            "numéro 11  de la  revue  de  poésie électronique  alire avec 28"\
            " créations poétiques  inédites, présentées sur un cédérom  "\
            "multimédia."
        ui.message("Text used as source (input file): {}".format(htext))
        ui.message("The hidden data is: {}"
                   "".format(spaces.unhide(htext)))

        ui.message("--- Won't work ---")
        data = "morderegrippipiotabirofreluchamburelurecoquelurintimpanemens"
        ui.message("+ The input text must be long enough (have enough letters)"
                   " for the given data to hide:")
        ui.message("Data to hide: {}".format(data))
        try:
            ui.message("Text with hidden data (output file): {}"
                       "".format(spaces.hide(text, data)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
Esempio n. 2
0
    def hide(self, ui):
        """Interactive version of hide()."""
        txt = ""
        ui.message("===== Hide Mode =====")

        while 1:
            done = False
            while not done:
                txt = ui.text_input("Text into which hide data")
                if txt is None:
                    break  # Go back to main Hide menu.

                while 1:
                    data = ui.text_input("Data to hide into the text",
                                         sub_type=ui.LOWER)
                    try:
                        # Will also raise an exception if data is None.
                        txt = spaces.hide(txt, data)
                        done = True  # Out of those loops, output result.
                        break
                    except Exception as e:
                        if utils.DEBUG:
                            import traceback
                            traceback.print_tb(sys.exc_info()[2])
                        ui.message(str(e), level=ui.ERROR)
                        options = [("retry", "*try again", ""),
                                   ("file", "choose another *input file", ""),
                                   ("menu", "or go back to *menu", "")]
                        msg = "Could not hide that data into the given " \
                              "text, please"
                        answ = ui.get_choice(msg, options, oneline=True)
                        if answ == "file":
                            break  # Go back to input file selection.
                        elif answ in {None, "menu"}:
                            return  # Go back to main Sema menu.
                        # Else, retry with another data to hide.

            if done:
                ui.text_output("Data successfully hidden", txt,
                               "Text with hidden data")

            options = [("redo", "*hide another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ in {None, "quit"}:
                return
Esempio n. 3
0
    def hide(self, ui):
        """Interactive version of hide()."""
        txt = ""
        ui.message("===== Hide Mode =====")

        while 1:
            done = False
            while not done:
                txt = ui.text_input("Text into which hide data")
                if txt is None:
                    break  # Go back to main Hide menu.

                while 1:
                    data = ui.text_input("Data to hide into the text",
                                         sub_type=ui.LOWER)
                    try:
                        # Will also raise an exception if data is None.
                        txt = spaces.hide(txt, data)
                        done = True  # Out of those loops, output result.
                        break
                    except Exception as e:
                        if utils.DEBUG:
                            import traceback
                            traceback.print_tb(sys.exc_info()[2])
                        ui.message(str(e), level=ui.ERROR)
                        options = [("retry", "*try again", ""),
                                   ("file", "choose another *input file", ""),
                                   ("menu", "or go back to *menu", "")]
                        msg = "Could not hide that data into the given " \
                              "text, please"
                        answ = ui.get_choice(msg, options, oneline=True)
                        if answ == "file":
                            break  # Go back to input file selection.
                        elif answ in {None, "menu"}:
                            return  # Go back to main Sema menu.
                        # Else, retry with another data to hide.

            if done:
                ui.text_output("Data successfully hidden", txt,
                               "Text with hidden data")

            options = [("redo", "*hide another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ in {None, "quit"}:
                return