A Python-based simulation of quantum-inspired cryptographic communication between Alice and Bob, with optional eavesdropper (Eve) interference.
This project demonstrates cryptographic concepts including:
- Quantum-inspired key generation and hashing
- AES-CBC encryption for secure message transmission
- Message integrity verification using cryptographic hashes
- Eavesdropper simulation to demonstrate tampering detection
- Quantum-Inspired Encryption: Optional quantum key generation for enhanced hash security
- Classical Encryption Fallback: Disable quantum features to use standard SHA-256 hashing
- Eavesdropper Simulation: Simulate man-in-the-middle attacks with Eve tampering messages
- Integrity Verification: Detect message tampering through hash comparison
- Clone the repository:
git clone https://github.com/MugishaProsper-Simulated-Quantum-Cryptography.git
cd Simulated-Quantum-Cryptography- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtpython main.pypython interface.pyRun the graphical interface:
python interface.pyFeatures:
- Toggle quantum encryption on/off
- Enable/disable eavesdropper simulation
- Configure Eve's tampering behavior
- Real-time color-coded communication log
- Generate new secret keys
- Clear log history
Run the command-line program:
python main.py-
Enable quantum encryption? (y/n)
y: Use quantum-inspired hashing with random quantum keysn: Use standard SHA-256 hashing
-
Simulate eavesdropper (Eve)? (y/n)
y: Enable Eve to intercept communicationn: Direct communication between Alice and Bob
-
Should Eve tamper with the message? (y/n)
- Only appears if Eve is enabled
- Modifies the encrypted message in transit
-
Should Eve tamper with the hash? (y/n)
- Only appears if Eve is enabled
- Modifies the encrypted hash in transit
=== Simulated Quantum Cryptography System ===
Enable quantum encryption? (y/n, default=y): y
Simulate eavesdropper (Eve)? (y/n, default=n): y
Should Eve tamper with the message? (y/n, default=y): y
Should Eve tamper with the hash? (y/n, default=n): n
==================================================
Enter your message: Hello, Bob!
[Alice] Message encrypted and sent
Encrypted message: 70q3AspF3ldk3UPdvOAZAg==+UHhgLzDbFv4KGuHNjRfAobmkL...
Encrypted hash: 7awrwEGRKonZasMe6LHwsA==xYE0toTlU297fFUmuT3eJ8KW6M...
Quantum mode: Enabled
[Eve] Intercepting communication...
Message tampered: True
Hash tampered: False
[Bob] Receiving and verifying message...
❌ Decryption/Verification failed: Padding is incorrect.
Simulated-Quantum-Cryptography/
├── main.py # Entry point and user interface
├── requirements.txt # Python dependencies
├── README.md # This file
├── docs/
│ ├── ARCHITECTURE.md # System architecture documentation
│ └── API.md # Module API reference
└── src/
├── __init__.py # Package initialization
├── communication.py # Alice and Bob communication protocol
├── encryptor.py # AES encryption utilities
├── decryptor.py # AES decryption utilities
├── hash_utils.py # Quantum-inspired hashing
├── quantum_key.py # Quantum key generation
├── eavesdropper.py # Eve tampering simulation
└── utils.py # General utilities
- A shared secret key is generated using
os.urandom() - If quantum mode is enabled, a quantum key is also generated for hashing
- Alice creates a hash of her message (with or without quantum key)
- The hash is encrypted with the shared secret key
- The message itself is also encrypted with the shared secret key
- Eve can intercept and tamper with encrypted messages or hashes
- Tampering modifies random characters in the encrypted data
- Bob decrypts both the message and the hash
- Bob recalculates the hash of the decrypted message
- If hashes match, integrity is verified; otherwise, tampering is detected
- This is NOT actual quantum cryptography (no quantum entanglement or superposition)
- Uses classical cryptographic primitives (AES, SHA-256)
- The "quantum" aspect simulates randomness and key distribution concepts
- Not suitable for production security applications
- Python 3.10+
- pycryptodome >= 3.19.0
This project is for educational purposes.
Contributions are welcome! Please feel free to submit issues or pull requests.