This project is a simple web application for encrypting and decrypting messages using a hybrid of the Vigenère and Polybius ciphers. It features a Python Flask backend and a modern HTML/CSS/JavaScript frontend.
Screenshot of the Hybrid Cipher Web Application
- 🔐 Hybrid Encryption: Combines Vigenère and Polybius ciphers for enhanced security
- 🌐 Web Interface: Clean, responsive HTML/CSS/JavaScript frontend
- 🔑 Flexible Keys: Supports both numeric and alphabetic encryption keys
- 📝 Text Preservation: Maintains spaces, punctuation, and special characters
- 🚀 RESTful API: Backend endpoints for programmatic access
- ⚡ Real-time Processing: Instant encryption and decryption
- 🎨 User-friendly: Intuitive interface with clear instructions
Hybrid-Cipher-Web-App/
├── app.py # Flask backend application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── images/ # Screenshots and documentation images
│ ├── 1.png # Main application screenshot
│ ├── 2.png # Encryption example
│ └── 3.png # Decryption example
├── static/ # Static web assets
│ ├── script.js # Frontend JavaScript
│ └── style.css # CSS styling
└── templates/ # HTML templates
└── index.html # Main web interface
- Python: 3.7 or higher
- pip: Python package installer
- Web Browser: Modern browser with JavaScript support
Flask: Web framework for PythonFlask-CORS: Cross-Origin Resource Sharing support
git clone https://github.com/shakiliitju/Hybrid-Cipher-Web-App.git
cd Hybrid-Cipher-Web-Apppython -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activatepip install -r requirements.txtpython app.pyOpen your browser and navigate to: http://127.0.0.1:5000
- Enter your message in the "Message / Cipher Text" field
- Enter your encryption key (supports both numbers and letters)
- Click "Encrypt" to convert your message to cipher text
- Copy the encrypted result and paste it back into the message field
- Click "Decrypt" to recover your original message
Step 1: Encrypting "defend the east wall in the castle" with key "SECRET"
Step 2: Decrypting the cipher text back to the original message
# Using the API directly
import requests
# Encrypt a message
response = requests.post('http://127.0.0.1:5000/encrypt',
json={'message': 'Hello World', 'key': 'SECRET'})
encrypted = response.json()['encrypted']
# Decrypt the message
response = requests.post('http://127.0.0.1:5000/decrypt',
json={'cipher': encrypted, 'key': 'SECRET'})
decrypted = response.json()['decrypted']Encrypts a plaintext message using the hybrid cipher.
Request Body:
{
"message": "YOUR_MESSAGE",
"key": "YOUR_KEY"
}Response:
{
"encrypted": "CIPHER_TEXT"
}Decrypts a cipher text back to the original message.
Request Body:
{
"cipher": "CIPHER_TEXT",
"key": "YOUR_KEY"
}Response:
{
"decrypted": "ORIGINAL_MESSAGE"
}Serves the main web interface.
This application uses a combination of two classical ciphers:
- Vigenère Cipher: A polyalphabetic substitution cipher that uses a keyword to shift letters
- Polybius Square: A substitution cipher that replaces letters with coordinate pairs
- Input text is converted to uppercase and 'J' is replaced with 'I'
- Vigenère cipher is applied using the provided key
- Polybius square transformation converts letters to number pairs
- Result is a string of digits representing the encrypted message
- Number pairs are converted back to letters using the Polybius square
- Vigenère decryption is applied using the same key
- Original message is recovered
Educational Purpose Only: This project is designed for:
- Learning classical cryptography concepts
- Understanding cipher combinations
- Web development demonstration
- API design examples
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
- Character Support: The cipher fully supports English letters (A-Z). Spaces, punctuation, and numbers are preserved but not encrypted
- Key Format: Supports both numeric keys (e.g., "12345") and alphabetic keys (e.g., "SECRET")
- Case Handling: Input is converted to uppercase for consistency
- File Structure: Ensure the
templatesandstaticfolders are in the same directory asapp.py - Dependencies: All required packages are listed in
requirements.txt
Port Already in Use:
# Kill process using port 5000
lsof -ti:5000 | xargs kill -9 # macOS/Linux
netstat -ano | findstr :5000 # WindowsModule Not Found:
# Ensure virtual environment is activated and dependencies installed
pip install -r requirements.txtCORS Errors:
- Flask-CORS is included to handle cross-origin requests
- Ensure Flask-CORS is properly installed
MIT License - feel free to use this project for educational purposes.
Md. Shakil Hossain
- GitHub: @shakiliitju
- Project: Hybrid-Cipher-Web-App