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

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

            codec = ui.get_data("Type the codec you want to use (e.g. "
                                "'utf-8'), or leave empty to use "
                                "default 'ascii' one: ")
            if not codec:
                codec = "ascii"

            try:
                ui.text_output("Data successfully decypherd",
                               binary.decypher(txt, codec),
                               "The hidden data 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
Esempio n. 2
0
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

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

            codec = ui.get_data("Type the codec you want to use (e.g. "
                                "'utf-8'), or leave empty to use "
                                "default 'ascii' one: ")
            if not codec:
                codec = "ascii"

            try:
                ui.text_output("Data successfully decypherd",
                               binary.decypher(txt, codec),
                               "The hidden data 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
Esempio n. 3
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

        ui.message("--- Encoding ---")
        ui.message("Data to cypher: {}\n".format("Hello World!"))
        ui.message("Binary cypherd data: {}"
                   "".format(binary.cypher("Hello World!")))
        ui.message("")

        htext = "01110111011001010110110001100011011011110110110101100101" \
                "00100001"
        ui.message("--- Decoding ---")
        ui.message("“Binary” text used as input: {}".format(htext))
        ui.message("The decypherd data is: {}".format(binary.decypher(htext)))

        ui.message("+ The input text to decypher may have space-separated "
                   "octets:")
        htext = "01110111 01100101 01101100 01100011 01101111 01101101 " \
                "01100101 00100001"
        ui.message("--- Decoding ---")
        ui.message("“Binary” text used as input: {}".format(htext))
        ui.message("The decypherd data is: {}".format(binary.decypher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to decypher must be (0, 1) digits only:")
        htext = "011001010111211101101100015000110110111101101101011a" \
                "001010010001"
        ui.message("“Binary” text used as input: {}".format(htext))
        try:
            ui.message("The decypherd data is: {}"
                       "".format(binary.decypher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.message("+ The input text to decypher must have a length multiple "
                   "of 8 (once spaces have been striped):")
        htext = "01100101 0110111 0110110 0110011 0110111 0101101 0110011 " \
                "0000001"
        ui.message("“Binary” text used as input: {}".format(htext))
        try:
            ui.message("The decypherd data is: {}"
                       "".format(binary.decypher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

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

        ui.message("--- Encoding ---")
        ui.message("Data to cypher: {}\n".format("Hello World!"))
        ui.message("Binary cypherd data: {}"
                   "".format(binary.cypher("Hello World!")))
        ui.message("")

        htext = "01110111011001010110110001100011011011110110110101100101" \
                "00100001"
        ui.message("--- Decoding ---")
        ui.message("“Binary” text used as input: {}".format(htext))
        ui.message("The decypherd data is: {}".format(binary.decypher(htext)))

        ui.message("+ The input text to decypher may have space-separated "
                   "octets:")
        htext = "01110111 01100101 01101100 01100011 01101111 01101101 " \
                "01100101 00100001"
        ui.message("--- Decoding ---")
        ui.message("“Binary” text used as input: {}".format(htext))
        ui.message("The decypherd data is: {}".format(binary.decypher(htext)))

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to decypher must be (0, 1) digits only:")
        htext = "011001010111211101101100015000110110111101101101011a" \
                "001010010001"
        ui.message("“Binary” text used as input: {}".format(htext))
        try:
            ui.message("The decypherd data is: {}"
                       "".format(binary.decypher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.message("+ The input text to decypher must have a length multiple "
                   "of 8 (once spaces have been striped):")
        htext = "01100101 0110111 0110110 0110011 0110111 0101101 0110011 " \
                "0000001"
        ui.message("“Binary” text used as input: {}".format(htext))
        try:
            ui.message("The decypherd data is: {}"
                       "".format(binary.decypher(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

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