Skip to content

This is a course project for the course computer communication and network in Hohai university in 2021/2022

License

Notifications You must be signed in to change notification settings

Yuming-Lee24/secure-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SecureChat - AES Encrypted Chat

Introduction (English)

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.

Features

  • 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.

Installation

Install dependencies

pip install pycryptodome

Usage

Start the Server

python server.py

The server will listen on 127.0.0.1:50000 and wait for two clients to connect.

Start a Client

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 or 9002).
  • Encryption Key: The same key must be used by both clients for successful decryption.

Security Notes

  • 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.

License

This project is open-source and licensed under the MIT License.


SecureChat - AES 加密聊天

简介(中文)

SecureChat 是一个使用 Python socketpycryptodome (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
  • 端口号:选择一个可用端口(如 90019002)。
  • 加密密钥:两个客户端必须使用相同的密钥才能正确解密消息。

安全说明

  • ECB 模式警告:当前版本使用 AES-ECB,该模式安全性较低,建议升级至 AES-CBCAES-GCM
  • 密钥管理:用户需确保密钥的安全性,避免泄露。
  • 服务器不解密消息:服务器仅转发加密消息,不对内容进行解析。

许可证

本项目基于 MIT 许可证开源。

About

This is a course project for the course computer communication and network in Hohai university in 2021/2022

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages