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

        text = "“En icelluy fut ladicte geneallogie trouvée, escripte au " \
               "long de lettres cancelleresques, non en papier, non en " \
               "parchemin, non en cere, mais en escorce d’ulmeau, tant " \
               "toutesfoys usées par vetusté qu’à poine en povoit on troys " \
               "recognoistre de ranc.” " \
               "– extrait de « Gargantua » de François Rabelais."

        ui.message("--- Hiding ---")
        data = "vieuxfrancois"
        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(alphaspaces.hide(text, data)))
        ui.message("")

        ui.message("--- Unhiding ---")
        htext = "“En                icelluy fut              ladicte" \
                "                    geneallogie trouvée,       escripte" \
                "                  au                     long     de" \
                "            lettres                           " \
                "cancelleresques, non en papier, non en parchemin, non en " \
                "cere, mais en escorce d’ulmeau, tant toutesfoys usées par " \
                "vetusté qu’à poine en povoit on troys recognoistre de " \
                "ranc.” – extrait de « Gargantua » de François Rabelais."
        ui.message("Text used as source (input file): {}".format(htext))
        ui.message("The hidden data is: {}"
                   "".format(alphaspaces.unhide(htext)))

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

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
示例#2
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

        text = "“En icelluy fut ladicte geneallogie trouvée, escripte au " \
               "long de lettres cancelleresques, non en papier, non en " \
               "parchemin, non en cere, mais en escorce d’ulmeau, tant " \
               "toutesfoys usées par vetusté qu’à poine en povoit on troys " \
               "recognoistre de ranc.” " \
               "– extrait de « Gargantua » de François Rabelais."

        ui.message("--- Hiding ---")
        data = "vieuxfrancois"
        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(alphaspaces.hide(text, data)))
        ui.message("")

        ui.message("--- Unhiding ---")
        htext = "“En                icelluy fut              ladicte" \
                "                    geneallogie trouvée,       escripte" \
                "                  au                     long     de" \
                "            lettres                           " \
                "cancelleresques, non en papier, non en parchemin, non en " \
                "cere, mais en escorce d’ulmeau, tant toutesfoys usées par " \
                "vetusté qu’à poine en povoit on troys recognoistre de " \
                "ranc.” – extrait de « Gargantua » de François Rabelais."
        ui.message("Text used as source (input file): {}".format(htext))
        ui.message("The hidden data is: {}"
                   "".format(alphaspaces.unhide(htext)))

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

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
示例#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 = alphaspaces.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
示例#4
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 = alphaspaces.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