Python E2E Encryption Demo is a simple project to show how end-to-end encryption works using public-private key pairs. Messages sent from User A to User B remain private — even the server cannot read them.
- Generate public and private keys for each user.
- Encrypt messages with the receiver’s public key.
- Decrypt messages with the receiver’s private key.
- Demonstrates the core concept of E2E encryption in a simple way.
-
Key Generation Each user creates their own public and private key pair.
-
Message Encryption Sender encrypts the message using the receiver’s public key.
-
Message Decryption Receiver decrypts the message using their private key.
-
Privacy Even if the message is intercepted, it cannot be read without the receiver’s private key.
- Generate keys for User A and User B.
- User A encrypts a message using User B’s public key.
- User B decrypts the message using their private key.
- User B can reply securely using User A’s public key.
- Start the server:
python main.py server- Start a client:
python main.py client- Follow the prompts to send encrypted messages between clients.
User A (sender) Server User B (receiver)
Public/Private Key Public/Private Key
| |
| Encrypt message using B's public key
|----------------------------------->|
| Receive encrypted message
| |
| Decrypt using B's private key
| |
Plain message Plain message
- This project is for learning purposes only.
- For real-world security, use a trusted crypto library.
