예제 #1
0
파일: binary.py 프로젝트: SAKAROV/Cyprium
    def decode(self, ui):
        """Interactive version of decode()."""
        txt = ""
        ui.message("===== Decode 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 decoded",
                               binary.decode(txt, codec),
                               "The hidden data is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

            options = [("redo", "*decode another data", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ == "quit":
                return
예제 #2
0
파일: binary.py 프로젝트: SAKAROV/Cyprium
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

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

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

        ui.message("+ The input text to decode 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 decoded data is: {}".format(binary.decode(htext)))

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

        ui.message("+ The input text to decode 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 decoded data is: {}"
                       "".format(binary.decode(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.get_choice("", [("", "Go back to *menu", "")], oneline=True)
예제 #3
0
파일: binary.py 프로젝트: SAKAROV/Cyprium
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")

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

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

        ui.message("+ The input text to decode 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 decoded data is: {}".format(binary.decode(htext)))

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

        ui.message("+ The input text to decode 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 decoded data is: {}" "".format(binary.decode(htext)))
        except Exception as e:
            ui.message(str(e), ui.ERROR)

        ui.get_choice("", [("", "Go back to *menu", "")], oneline=True)
예제 #4
0
파일: binary.py 프로젝트: SAKAROV/Cyprium
    def decode(self, ui):
        """Interactive version of decode()."""
        txt = ""
        ui.message("===== Decode 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 decoded", binary.decode(txt, codec), "The hidden data is")
            except Exception as e:
                ui.message(str(e), ui.ERROR)

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