예제 #1
0
파일: argots.py 프로젝트: 47-/Cyprium
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

        while 1:
            txt = ui.text_input("Please choose some atomic digits text")
            syllable = None
            method = argots.GENERIC

            # Get obfuscating method.
            options = [(argots.JAVANAIS,
                        "*javanais decyphering", ""),
                       (argots.FEU, "langue de *feu", ""),
                       (argots.GENERIC, "$generic", ""),
                       (argots.LARGONJI,
                        "or *largonji des loucherbèmes one", "")]
            method = ui.get_choice("Do you want to use", options,
                                   oneline=True)

            if method == argots.LARGONJI:
                # Get sets of suffix syllables.
                v_sylb = argots.LARGONJI_SYLLABLES_V
                s = ui.get_data("Suffix vowel-compliant syllables, comma "
                                "separated (or nothing to use default "
                                "'{}' ones): "
                                "".format("', '".join(v_sylb)),
                                allow_void=True)
                if s:
                    v_sylb = [s.strip() for s in s.split(",")]

                c_sylb = argots.LARGONJI_SYLLABLES_C
                s = ui.get_data("Suffix consonant-compliant syllables, "
                                "comma separated (or nothing to use "
                                "default '{}' ones): "
                                "".format("', '".join(c_sylb)),
                                allow_void=True)
                if s:
                    c_sylb = [s.strip() for s in s.split(",")]

            else:
                # Get obfuscating syllable.
                s = ui.get_data("Obfuscating syllable (or nothing to search "
                                "for the most common one): ", allow_void=True,
                                validate=self._validate,
                                validate_kwargs={'method': method})
                if s:
                    syllable = s

            try:
                if method == argots.LARGONJI:
                    txt = argots.decypher_largonji(txt, v_sylb, c_sylb)
                    txt = "\n    " + \
                          "\n    ".join(utils.format_multiwords(txt))
                else:
                    txt = argots.decypher(txt, method, syllable)
                    if len(txt) > 1:
                        txt = "\n    " + \
                              "\n".join(["Using '{}':\n    {}"
                                         "".format(t[0], t[1]) for t in txt])
                    elif txt:
                        txt = txt[0][1]
                    else:
                        txt = ""
                ui.text_output("Text successfully decyphered",
                               txt, "The decyphered text is")
            except Exception as e:
                if utils.DEBUG:
                    import traceback
                    traceback.print_tb(sys.exc_info()[2])
                ui.message(str(e), level=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
예제 #2
0
파일: argots.py 프로젝트: underloki/Cyprium
    def decypher(self, ui):
        """Interactive version of decypher()."""
        txt = ""
        ui.message("===== Decypher Mode =====")

        while 1:
            txt = ui.text_input("Please choose some atomic digits text")
            syllable = None
            method = argots.GENERIC

            # Get obfuscating method.
            options = [(argots.JAVANAIS, "*javanais decyphering", ""),
                       (argots.FEU, "langue de *feu", ""),
                       (argots.GENERIC, "$generic", ""),
                       (argots.LARGONJI, "or *largonji des loucherbèmes one",
                        "")]
            method = ui.get_choice("Do you want to use", options, oneline=True)

            if method == argots.LARGONJI:
                # Get sets of suffix syllables.
                v_sylb = argots.LARGONJI_SYLLABLES_V
                s = ui.get_data("Suffix vowel-compliant syllables, comma "
                                "separated (or nothing to use default "
                                "'{}' ones): "
                                "".format("', '".join(v_sylb)),
                                allow_void=True)
                if s:
                    v_sylb = [s.strip() for s in s.split(",")]

                c_sylb = argots.LARGONJI_SYLLABLES_C
                s = ui.get_data("Suffix consonant-compliant syllables, "
                                "comma separated (or nothing to use "
                                "default '{}' ones): "
                                "".format("', '".join(c_sylb)),
                                allow_void=True)
                if s:
                    c_sylb = [s.strip() for s in s.split(",")]

            else:
                # Get obfuscating syllable.
                s = ui.get_data(
                    "Obfuscating syllable (or nothing to search "
                    "for the most common one): ",
                    allow_void=True,
                    validate=self._validate,
                    validate_kwargs={'method': method})
                if s:
                    syllable = s

            try:
                if method == argots.LARGONJI:
                    txt = argots.decypher_largonji(txt, v_sylb, c_sylb)
                    txt = "\n    " + \
                          "\n    ".join(utils.format_multiwords(txt))
                else:
                    txt = argots.decypher(txt, method, syllable)
                    if len(txt) > 1:
                        txt = "\n    " + \
                              "\n".join(["Using '{}':\n    {}"
                                         "".format(t[0], t[1]) for t in txt])
                    elif txt:
                        txt = txt[0][1]
                    else:
                        txt = ""
                ui.text_output("Text successfully decyphered", txt,
                               "The decyphered text is")
            except Exception as e:
                if utils.DEBUG:
                    import traceback
                    traceback.print_tb(sys.exc_info()[2])
                ui.message(str(e), level=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
예제 #3
0
파일: argots.py 프로젝트: 47-/Cyprium
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")
        ui.message("")

        ui.message("--- Cyphering ---")
        ui.message("+ Argot Javanais & co.")
        text = "Les « Blousons Noirs » vous parlent…"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher(text, argots.JAVANAIS, 'av')
        ui.message("Argot Javanais with 'av': {}".format(out))
        ui.message("")

        ui.message("+ Largonji des Loucherbèmes.")
        text = "Les bouchers de la Villette osent un tango langoureux !"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher_largonji(text, argots.LARGONJI_SYLLABLES_V,
                                     argots.LARGONJI_SYLLABLES_C)
        out = self._get_largonji_txt(out, ui, act="rand")
        ui.message("Largonji des Loucherbèmes: {}".format(out))
        ui.message("")

        ui.message("--- Decyphering ---")
        ui.message("+ Argot Javanais & co.")
        htext = "LEfes EfApEfachEfes sEfont sEfur lEfe sEfentEfier dEfes " \
                "HEfallEfes."
        ui.message("Note that most of the time, you can use default options "
                   "here (i.e. Generic, and give no obfuscating syllable), "
                   "as that kind of “cyphering” is really easy to break!")
        ui.message("Langue de Feu text used as input: {}".format(htext))
        out = argots.decypher(htext, argots.FEU)
        ui.message("The decyphered data is:\n    With '{}': {}"
                   "".format(out[0][0], out[0][1]))
        ui.message("")

        ui.message("+ Largonji des Loucherbèmes.")
        htext = "La mie du loucherbouche lricottefesse lavecouche le " \
                "loulangerbesse !"
        ui.message("Largonji de Loucherbems text used as input: {}"
                   "".format(htext))
        out = argots.decypher_largonji(htext)
        ui.message("The decyphered data is:\n    {}"
                   "".format("\n    ".join(utils.format_multiwords(out))))
        ui.message("")

        ui.message("--- Notes ---")
        ui.message("+ With Argot Javanais & co, you can choose the optional "
                   "Exhaustive option, to get all possible encodings of each "
                   "words higher than the given goal of cyphering (or the "
                   "highest possible):")
        text = "Do you know Ménilmuche and Belleville ?"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher(text, argots.GENERIC, 'uz', exhaustive=True,
                            cypher_goal=0.2)
        out = self._get_exhaustive_txt(out, ui, cypher_goal=0.2, act="goal")
        ui.message("Generic cyphered solutions with cypher factor higher "
                   "than 0.2:")
        ui.message(out)
        ui.message("")

        ui.message("+ Here is what you’ll get if you try to decypher some "
                   "largonji without giving any suffix syllables (note how "
                   "some words aren’t decyphered well at all):")
        htext = "La mie du loucherbouche lricottefesse lavecouche le " \
                "loulangerbesse !"
        ui.message("Largonji de Loucherbems text used as input: {}"
                   "".format(htext))
        out = argots.decypher_largonji(htext, (), ())
        ui.message("The decyphered data is:\n    {}"
                   "".format("\n    ".join(utils.format_multiwords(out))))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ With Argot Javanais & co, the obfuscating syllable "
                   "must comply to the chosen method!")
        text = "Hello WORLD !"
        ui.message("Data to cypher, using Javanais and 'eh': {}\n"
                   "".format(text))
        try:
            out = argots.cypher(text, argots.JAVANAIS, 'eh')
            ui.message("Javanais cyphered data: {}".format(out))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

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

        ui.message("--- Cyphering ---")
        ui.message("+ Argot Javanais & co.")
        text = "Les « Blousons Noirs » vous parlent…"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher(text, argots.JAVANAIS, 'av')
        ui.message("Argot Javanais with 'av': {}".format(out))
        ui.message("")

        ui.message("+ Largonji des Loucherbèmes.")
        text = "Les bouchers de la Villette osent un tango langoureux !"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher_largonji(text, argots.LARGONJI_SYLLABLES_V,
                                     argots.LARGONJI_SYLLABLES_C)
        out = self._get_largonji_txt(out, ui, act="rand")
        ui.message("Largonji des Loucherbèmes: {}".format(out))
        ui.message("")

        ui.message("--- Decyphering ---")
        ui.message("+ Argot Javanais & co.")
        htext = "LEfes EfApEfachEfes sEfont sEfur lEfe sEfentEfier dEfes " \
                "HEfallEfes."
        ui.message("Note that most of the time, you can use default options "
                   "here (i.e. Generic, and give no obfuscating syllable), "
                   "as that kind of “cyphering” is really easy to break!")
        ui.message("Langue de Feu text used as input: {}".format(htext))
        out = argots.decypher(htext, argots.FEU)
        ui.message("The decyphered data is:\n    With '{}': {}"
                   "".format(out[0][0], out[0][1]))
        ui.message("")

        ui.message("+ Largonji des Loucherbèmes.")
        htext = "La mie du loucherbouche lricottefesse lavecouche le " \
                "loulangerbesse !"
        ui.message("Largonji de Loucherbems text used as input: {}"
                   "".format(htext))
        out = argots.decypher_largonji(htext)
        ui.message("The decyphered data is:\n    {}"
                   "".format("\n    ".join(utils.format_multiwords(out))))
        ui.message("")

        ui.message("--- Notes ---")
        ui.message("+ With Argot Javanais & co, you can choose the optional "
                   "Exhaustive option, to get all possible encodings of each "
                   "words higher than the given goal of cyphering (or the "
                   "highest possible):")
        text = "Do you know Ménilmuche and Belleville ?"
        ui.message("Data to cypher: {}".format(text))
        out = argots.cypher(text,
                            argots.GENERIC,
                            'uz',
                            exhaustive=True,
                            cypher_goal=0.2)
        out = self._get_exhaustive_txt(out, ui, cypher_goal=0.2, act="goal")
        ui.message("Generic cyphered solutions with cypher factor higher "
                   "than 0.2:")
        ui.message(out)
        ui.message("")

        ui.message("+ Here is what you’ll get if you try to decypher some "
                   "largonji without giving any suffix syllables (note how "
                   "some words aren’t decyphered well at all):")
        htext = "La mie du loucherbouche lricottefesse lavecouche le " \
                "loulangerbesse !"
        ui.message("Largonji de Loucherbems text used as input: {}"
                   "".format(htext))
        out = argots.decypher_largonji(htext, (), ())
        ui.message("The decyphered data is:\n    {}"
                   "".format("\n    ".join(utils.format_multiwords(out))))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ With Argot Javanais & co, the obfuscating syllable "
                   "must comply to the chosen method!")
        text = "Hello WORLD !"
        ui.message("Data to cypher, using Javanais and 'eh': {}\n"
                   "".format(text))
        try:
            out = argots.cypher(text, argots.JAVANAIS, 'eh')
            ui.message("Javanais cyphered data: {}".format(out))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

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