Starting the web server
Launch the Flask application
Start the web server:The application will start on
http://localhost:5000 by default.Interface overview
The web interface consists of a single-page application with the following elements:- Message input: A textarea where you enter the text to encrypt or decrypt
- Operation selector: Choose between “Cifrar” (Encrypt) or “Descifrar” (Decrypt)
- Algorithm selector: Select from Sustitución (César), Transposición, or RSA
- Process button: Submit the form to perform the operation
- Result display: Shows the encrypted/decrypted output
- Additional info: For RSA, displays generated keys and instructions
Using different algorithms
- Sustitución (César)
- Transposición
- RSA
The Caesar cipher shifts letters by a fixed position (default: 8 positions).
Encrypting a message
- Enter your plaintext message in the “Mensaje” field
- Select ”🔒 Cifrar” from the Operation dropdown
- Select ”🔄 Sustitución (César)” from the Type dropdown
- Click “Procesar ✨”
- Input:
HOLA MUNDO - Output:
OWSITCULW
Decrypting a message
- Enter the encrypted text in the “Mensaje” field
- Select ”🔓 Descifrar” from the Operation dropdown
- Select ”🔄 Sustitución (César)” from the Type dropdown
- Click “Procesar ✨”
- Input:
OWSITCULW - Output:
HOLAMUNDO
The shift position is fixed at 8 in the web interface. Spaces are removed from the output.
Understanding the workflow
The web application uses Flask sessions to manage RSA keys and processes requests through the following flow:- Form submission: User submits message, operation, and algorithm type
- Algorithm routing: Based on
tipo_cifrado, the appropriate function is called - Session management: For RSA, keys are stored in Flask session
- Result rendering: Output is displayed in the result container
Common issues and solutions
RSA decryption error: No hay claves RSA en la sesión
RSA decryption error: No hay claves RSA en la sesión
Problem: You’re trying to decrypt without first encrypting a message.Solution: Encrypt a message first to generate keys, then copy the encrypted list to decrypt.
RSA decryption error: El formato del mensaje cifrado no es válido
RSA decryption error: El formato del mensaje cifrado no es válido
Problem: The encrypted message wasn’t pasted in the correct format.Solution: Ensure you’re pasting the complete list with brackets:
[123, 456, 789]Unexpected characters in output
Unexpected characters in output
Problem: The algorithms may add padding (
*) or remove spaces.Solution: This is expected behavior. Spaces are removed in substitution cipher, and * is used for padding in transposition.Technical details
The web interface is implemented inapp.py with the following key features:
- Secret key: Uses Flask sessions with a secret key (line 8)
- Fixed parameters: Substitution uses shift=8, Transposition uses key=5
- RSA key size: Generates 32-bit keys (suitable for educational purposes only)
- Session storage: RSA keys (e, d, n) are stored in Flask session for reuse