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

        ui.message("--- Encrypting ---")
        ui.message("Data to encrypt: {}\n".format("Hello Wolrd !"))
        ui.message("Braille encrypted data: {}"
                   "".format(braille.encrypt("Hello Wolrd !")))

        htext = "13457 24 14 15  2345 15 234 2345 6  24 234 1345 3457 2345  " \
                "24 2345 168 1456"
        ui.message("--- Deciphering ---")
        ui.message("Braille text used as input: {}".format(htext))
        ui.message("The deciphered data is: {}"
                   "".format(braille.decipher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to encrypt must be cp1252 (Windows "
                   "8bit occidental charset) chars only:")
        ui.message("Data to encrypt: {}\n".format("Japanese : 日本の"))
        try:
            ui.message("Braille encrypted data: {}"
                       "".format(braille.encrypt("Japanese : 日本の")))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.message("+ The input text to decipher must be valid Braille "
                   "us-437 codes only:")
        htext = "13447 24 14 15  2345 15 234 2345 6  24 234 1345 3457 2345  " \
                "24 2345 1778 1456"
        ui.message("Braille text used as input: {}".format(htext))
        try:
            ui.message("The deciphered data is: {}"
                       "".format(braille.decipher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

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

        ui.message("--- Encrypting ---")
        ui.message("Data to encrypt: {}\n".format("Hello Wolrd !"))
        ui.message("Braille encrypted data: {}"
                   "".format(braille.encrypt("Hello Wolrd !")))

        htext = "13457 24 14 15  2345 15 234 2345 6  24 234 1345 3457 2345  " \
                "24 2345 168 1456"
        ui.message("--- Deciphering ---")
        ui.message("Braille text used as input: {}".format(htext))
        ui.message("The deciphered data is: {}"
                   "".format(braille.decipher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to encrypt must be cp1252 (Windows "
                   "8bit occidental charset) chars only:")
        ui.message("Data to encrypt: {}\n".format("Japanese : 日本の"))
        try:
            ui.message("Braille encrypted data: {}"
                       "".format(braille.encrypt("Japanese : 日本の")))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.message("+ The input text to decipher must be valid Braille "
                   "us-437 codes only:")
        htext = "13447 24 14 15  2345 15 234 2345 6  24 234 1345 3457 2345  " \
                "24 2345 1778 1456"
        ui.message("Braille text used as input: {}".format(htext))
        try:
            ui.message("The deciphered data is: {}"
                       "".format(braille.decipher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.get_choice("", [("", "Go back to *menu", "")], oneline=True)
Example #3
0
    def decipher(self, ui):
        """Interactive version of decipher()."""
        txt = ""
        ui.message("===== Decipher Mode =====")

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

            try:
                ui.text_output("Text successfully deciphered",
                               braille.decipher(txt), "The deciphered text is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

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

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

            try:
                ui.text_output("Text successfully deciphered",
                               braille.decipher(txt),
                               "The deciphered text is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

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