def demo(self, ui): ui.message("===== Demo Mode =====") ui.message("Running a small demo/testing!") text = "bienvenu à tous dans cyprium.upper_lower by the"\ "the hachakemy. merci à chacun d'entre vous." ui.message("--- Hiding ---") data = "THA" ui.message("Text used as source (input file): {}".format(text)) ui.message("Data to hide: {}\n".format(data)) ui.message("Text with hidden data (output file): {}" "".format(upper_lower.hide(text, data))) ui.message("") ui.message("--- Unhiding ---") htext = "aSkdfJaÖSDkfJaSÖDFjaSDKFasjfks" ui.message("Text used as source (input file): {}".format(htext)) ui.message("The hidden data is: {}" "".format(upper_lower.unhide(htext))) ui.message("--- Won't work ---") data = "morderegrippipiotabirofreluchamburelurecoquelurintimpanemens" ui.message("+ The input text must be long enough (have enough letters)" " for the given data to hide:") ui.message("Data to hide: {}".format(data)) try: ui.message("Text with hidden data (output file): {}" "".format(upper_lower.hide(text, data))) except Exception as e: ui.message(str(e), level=ui.ERROR) ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
def hide(self, ui): """Interactive version of hide().""" txt = "" ui.message("===== Hide Mode =====") while 1: done = False while not done: txt = ui.text_input("Text into which hide data") if txt is None: break # Go back to main Hide menu. while 1: data = ui.text_input("Data to hide into the text", sub_type=ui.LOWER) options = [(0, "$0==lower-case", ''), (1, "*1==lower-case", '')] msg = "Choose the hiding-mode :" mode = ui.get_choice(msg, options, oneline=True) try: # Will also raise an exception if data is None. txt = upper_lower.hide(txt, data, mode) done = True # Out of those loops, output result. break except Exception as e: if utils.DEBUG: import traceback traceback.print_tb(sys.exc_info()[2]) ui.message(str(e), level=ui.ERROR) options = [("retry", "*try again", ""), ("file", "choose another *input file", ""), ("menu", "or go back to *menu", "")] msg = "Could not hide that data into the given " \ "text, please" answ = ui.get_choice(msg, options, oneline=True) if answ == "file": break # Go back to input file selection. elif answ in {None, "menu"}: return # Go back to main Sema menu. # Else, retry with another data to hide. if done: ui.text_output("Data successfully hidden", txt, "Text with hidden data") options = [("redo", "*hide another data", ""), ("quit", "or go back to *menu", "")] answ = ui.get_choice("Do you want to", options, oneline=True) if answ in {None, "quit"}: return