SecureChat is a simple encrypted chat application using Python's socket
and pycryptodome
(AES). This project allows two clients to communicate securely over TCP with end-to-end encryption.
- AES Encryption (ECB Mode): Messages are encrypted using AES-256 before being transmitted.
- Secure Key Derivation: Uses SHA-256 hashing to generate a strong encryption key.
- Simple Chat Interface: Real-time message exchange between two clients through a server.
- Multi-platform: Works on any system with Python 3.
pip install pycryptodome
python server.py
The server will listen on 127.0.0.1:50000
and wait for two clients to connect.
python client.py
When prompted, enter your IP address, port, and encryption key.
- IP Address: Enter the local IP or leave it as
127.0.0.1
for local testing. - Port: Choose an available port (e.g.,
9001
or9002
). - Encryption Key: The same key must be used by both clients for successful decryption.
- ECB Mode Warning: The current implementation uses AES-ECB, which is not the most secure mode. Consider upgrading to AES-CBC or AES-GCM.
- Key Management: Users must share the encryption key securely.
- Server Does Not Decrypt Messages: The server only forwards encrypted messages between clients.
This project is open-source and licensed under the MIT License.
SecureChat 是一个使用 Python socket
和 pycryptodome
(AES) 实现的简单加密聊天应用。该项目允许两个客户端通过 TCP 进行端到端加密通信。
- AES 加密 (ECB 模式):消息在传输前使用 AES-256 进行加密。
- 安全密钥派生:使用 SHA-256 哈希算法生成安全加密密钥。
- 简单聊天界面:两个客户端通过服务器进行实时消息传输。
- 多平台兼容:适用于所有支持 Python 3 的操作系统。
pip install pycryptodome
python server.py
服务器将在 127.0.0.1:50000
监听并等待两个客户端连接。
python client.py
运行后,输入以下信息:
- IP 地址:输入本机 IP,或在本地测试时使用
127.0.0.1
。 - 端口号:选择一个可用端口(如
9001
或9002
)。 - 加密密钥:两个客户端必须使用相同的密钥才能正确解密消息。
- ECB 模式警告:当前版本使用 AES-ECB,该模式安全性较低,建议升级至 AES-CBC 或 AES-GCM。
- 密钥管理:用户需确保密钥的安全性,避免泄露。
- 服务器不解密消息:服务器仅转发加密消息,不对内容进行解析。
本项目基于 MIT 许可证开源。