Exemple #1
0
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

        while 1:
            txt = ui.text_input("Please choose some chinesecypher text")

            try:
                ui.text_output("Text successfully decyphered",
                               chinesecypher.decypher(txt),
                               "The decyphered text is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

            options = [("redo", "*decypher another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ == "quit":
                return
Exemple #2
0
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

        while 1:
            txt = ui.text_input("Please choose some chinesecypher text")

            try:
                ui.text_output("Text successfully decyphered",
                               chinesecypher.decypher(txt),
                               "The decyphered text is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

            options = [("redo", "*decypher another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ == "quit":
                return
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!\n")

        ui.message("--- Cyphering ---")
        text = "china is a big country"
        ui.message("Data to cypher: {}\n".format(text))
        ui.message("ChineseCypher cyphered data, (Chinese, Samurai and "
                   "digits):\n    {}"
                   "".format("\n    "
                             "".join(chinesecypher.cypher(text,
                                                          chinese=True,
                                                          samurai=True,
                                                          digits=True))))
        ui.message("")

        ui.message("--- Decyphering Chinese version ---")
        htext = "————||||| ——||| ——  " \
                "——||| — —|| ———|| — —||| —— ———|||| ——————"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Decyphering Samurai version ---")
        htext = "||||————— ||——— ||  " \
                "||——— | |—— |||—— | |——— || |||———— ||||||"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Decyphering Digits version ---")
        htext = "45 23 20  23 10 12 32 10 13 20 34 60"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be acsii lowercase "
                   "letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("ChineseCypher cyphered data: {}"
                       "".format(chinesecypher.cypher("Hello World!",
                                                      chinese=True)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

        ui.message("+ The input text to decypher must be phone digits only:")
        htext = "49 23 ||———  23 10 12 ———|| 10 13 88 34 60"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(chinesecypher.decypher(htext)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

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

        ui.message("--- Cyphering ---")
        text = "china is a big country"
        ui.message("Data to cypher: {}\n".format(text))
        ui.message("ChineseCypher cyphered data, (Chinese, Samurai and "
                   "digits):\n    {}"
                   "".format("\n    "
                             "".join(
                                 chinesecypher.cypher(text,
                                                      chinese=True,
                                                      samurai=True,
                                                      digits=True))))
        ui.message("")

        ui.message("--- Decyphering Chinese version ---")
        htext = "————||||| ——||| ——  " \
                "——||| — —|| ———|| — —||| —— ———|||| ——————"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Decyphering Samurai version ---")
        htext = "||||————— ||——— ||  " \
                "||——— | |—— |||—— | |——— || |||———— ||||||"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Decyphering Digits version ---")
        htext = "45 23 20  23 10 12 32 10 13 20 34 60"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(chinesecypher.decypher(htext)))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be acsii lowercase "
                   "letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("ChineseCypher cyphered data: {}"
                       "".format(
                           chinesecypher.cypher("Hello World!", chinese=True)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)
        ui.message("")

        ui.message("+ The input text to decypher must be phone digits only:")
        htext = "49 23 ||———  23 10 12 ———|| 10 13 88 34 60"
        ui.message("ChineseCypher text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(chinesecypher.decypher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)
        ui.message("")

        ui.get_choice("", [("", "Go back to *menu", "")], oneline=True)