Helper functions for user input and output formatting in cryptography operations
The util module provides utility functions for interacting with users through the command-line interface, including input prompts and formatted output display.
import util# Prompt user for a messagemensaje = util.pedirmsj("Ingrese el mensaje a operar: ")print(f"You entered: {mensaje}")# Example interaction:# > Ingrese el mensaje a operar: hola mundo# El mensaje es: HOLA MUNDO
import utilimport sustituciondef main(): # Get message from user mensaje = util.pedirmsj("Ingrese el mensaje a operar: ") print(f'Mensaje original: {mensaje}') # Use the message for encryption pos = 8 cifrado = sustitucion.convertiraNumero(mensaje) cifrado = sustitucion.cifrar(cifrado, pos) mensajecifrado = sustitucion.convertiraLetra(cifrado)
This function does not return a value. It prints the result and pauses for 1 second.
The function includes a 1-second sleep after displaying the result, which helps create a better user experience by preventing output from scrolling too quickly in batch operations.
Custom scripts that need user input/output formatting
These utility functions are designed for command-line applications. For web applications (like the Flask app in app.py), these functions are not used since input/output is handled through HTML forms and templates.