This project is a back-end API for a secure real-time chat application. It provides functionalities for user management, private messaging, and secure file sharing. The application ensures the confidentiality of communications through end-to-end encryption and also uses compression for file transfers.
- Real-time Chat: Utilizes SignalR for instant messaging between users.
- End-to-End Encryption: Implements a combination of Diffie-Hellman key exchange and SDES encryption to secure messages. All messages are stored in an encrypted format in the database.
- Secure File Sharing: Allows users to share files that are encrypted with SDES and compressed using the LZW algorithm before being transferred.
- User and Contact Management: Provides endpoints for user registration, login, and managing contact lists.
The solution is divided into three main projects:
ChatAPI: The main ASP.NET Core Web API project that exposes the endpoints for the chat application. It handles all the business logic, including user authentication, message handling, and file processing.Encryptors: A class library project that contains the implementations of the encryption algorithms used in the application, such as Caesar cipher, Diffie-Hellman, and SDES.Compressor: A class library project that contains the implementation of the LZW compression algorithm.
-
Clone the repository:
Clone this repository to your local machine and navigate to the project's root directory.
-
Configure the database connection:
Open the
ChatAPI/appsettings.jsonfile and modify theChatDatabaseSettingssection with your MongoDB connection string and database name."ChatDatabaseSettings": { "ConnectionString": "mongodb://localhost:27017", "DatabaseName": "ChatDB" }
-
Run the application:
Navigate to the
ChatAPIdirectory and use thedotnet runcommand to start the server.cd ChatAPI dotnet runThe API will be running on the port specified in the
Properties/launchSettings.jsonfile (typicallyhttps://localhost:5001orhttp://localhost:5000).
The following are the main endpoints provided by the ChatController:
GET /api/chat/{sender}/{receiver}: Retrieves the decrypted chat history between two users.POST /api/chat/send/private/{senderCode}: Sends a private text message to a user. The message is encrypted before being stored.POST /api/chat/send/private/file: Uploads a file, which is then encrypted and compressed.GET /api/chat/{id}/download: Downloads a file, which is decompressed and decrypted on the server before being sent to the client.
GET /api/user: Retrieves a list of all users.GET /api/user/username/{username}: Retrieves a specific user by their username.GET /api/user/{id}: Retrieves a specific user by their ID.POST /api/user: Registers a new user.POST /api/user/login: Logs in a user.PUT /api/user/{id}: Updates a user's information.DELETE /api/user/{id}: Deletes a user.GET /api/user/image/{photo}: Retrieves a user's profile picture.POST /api/user/upload/{id}: Uploads a profile picture for a user.
GET /api/contact/{id}: Retrieves a specific contact by their ID.GET /api/contact/{username}: Retrieves a list of contacts for a specific user.POST /api/contact: Creates a new contact.
GET /api/invitation/{id}: Retrieves a specific invitation by its ID.GET /api/invitation/{username}: Retrieves a list of invitations for a specific user.POST /api/invitation: Creates a new invitation.POST /api/invitation/action: Accepts or declines an invitation.
socket: The SignalR hub endpoint for real-time communication.