A simple end-to-end encrypted chat application built in Python using sockets and the cryptography
library. This tool allows two users to chat securely over a network using symmetric encryption (Fernet).
- Peer-to-peer encrypted messaging
- End-to-end symmetric encryption with Fernet
- Chat history displayed in real time
- Host or connect modes
- Simple and minimal codebase (~100 lines)
- Python 3.x
cryptography
library
Install dependencies with:
pip install cryptography
- Clone the repository:
git clone https://github.com/your-username/encrypted-chat.git
cd encrypted-chat
- Run the script:
python chat.py
- Choose one machine to host the connection (listen), and the other to connect:
Hva heter du: Alice
(l)isten eller (c)onnect (l er host, c er kobling mot motpart)? l
Hva heter du: Bob
(l)isten eller (c)onnect (l er host, c er kobling mot motpart)? c
Skriv inn IPen til motparten: 192.168.x.x
Once connected, you can begin chatting securely.
Note: This project uses a hardcoded symmetric key:
key = "ab-YPb_Hzm0_eypRz0bG8bLeReGB1guJvQnYiuCxJoE="
In production use, you should:
- Generate a new key using Fernet.generate_key()
- Securely exchange or store the key
- Avoid hardcoding secrets
This is a minimal proof-of-concept chat system meant for educational or personal testing. Do not use this in production or expose it to untrusted networks without further security enhancements.
This project is open-source and available under the MIT License.