Skip to main content
The web interface provides an intuitive way to encrypt and decrypt messages using all three supported algorithms. This guide will walk you through using the Flask application.

Starting the web server

1

Activate the environment

First, activate the Pipenv virtual environment:
pipenv shell
2

Launch the Flask application

Start the web server:
python app.py
The application will start on http://localhost:5000 by default.
3

Open in browser

Navigate to http://localhost:5000 in your web browser to access the interface.

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

The Caesar cipher shifts letters by a fixed position (default: 8 positions).

Encrypting a message

  1. Enter your plaintext message in the “Mensaje” field
  2. Select ”🔒 Cifrar” from the Operation dropdown
  3. Select ”🔄 Sustitución (César)” from the Type dropdown
  4. Click “Procesar ✨”
Example:
  • Input: HOLA MUNDO
  • Output: OWSITCULW

Decrypting a message

  1. Enter the encrypted text in the “Mensaje” field
  2. Select ”🔓 Descifrar” from the Operation dropdown
  3. Select ”🔄 Sustitución (César)” from the Type dropdown
  4. Click “Procesar ✨”
Example:
  • 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:
app.py:10-38
  1. Form submission: User submits message, operation, and algorithm type
  2. Algorithm routing: Based on tipo_cifrado, the appropriate function is called
  3. Session management: For RSA, keys are stored in Flask session
  4. Result rendering: Output is displayed in the result container

Common issues and solutions

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.
Problem: The encrypted message wasn’t pasted in the correct format.Solution: Ensure you’re pasting the complete list with brackets: [123, 456, 789]
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 in app.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
This implementation is for educational purposes only. The 32-bit RSA keys and simple Caesar/transposition ciphers are not secure for real-world use.

Build docs developers (and LLMs) love