A lightweight client/server file transfer system written in C++ using raw TCP sockets, with chunked streaming and a simple XOR-based encryption layer.
- Custom TCP client/server implementation (single binary mode)
- Chunked file transfer over sockets
- XOR-based encryption/decryption layer
- Configurable packet size
- File integrity check via system MD5
- Packet-level debug output (useful for learning/debugging)
send-file/
│
├── include/
│ ├── network.h
│ ├── file_io.h
│ ├── crypto.h
│ └── util.h
│
├── src/
│ ├── main.cpp
│ ├── network.cpp
│ ├── file_io.cpp
│ ├── crypto.cpp
│ └── util.cpp
│
├── test.txt
├── Makefile
└── README.md
make
make clean
This produces:
sendfile
./sendfile server
You will be prompted for:
- Port number
- Output file name
- Encryption key
./sendfile client
You will be prompted for:
- Server IP address
- Port number
- File to send
- Packet size (bytes)
- Encryption key
./sendfile server
Port#: 8080
Save file to: output.txt
Enter encryption key: test
./sendfile client
Connect to IP address: 127.0.0.1
Port#: 8080
File to be sent: test.txt
Pkt size: 1024
Enter encryption key: test
This project uses a simple XOR cipher:
- Same key is used for encryption and decryption
- Applied before sending and after receiving
- Intended for learning purposes, not security
- Client reads file into memory
- File is encrypted using XOR key
- Data is sent in fixed-size packets over TCP
- Server receives and reconstructs file
- Server decrypts using same key
- Output file is written to disk
You can test locally using the included sample file:
test.txt
- Start the server:
./sendfile server
- In another terminal, run the client:
./sendfile client
- Use:
- IP:
127.0.0.1 - Same port on both
- Same encryption key on both
- File:
test.txt
This will transfer the file locally and verify the full workflow.
- Server must be started before client
- Same port and encryption key must be used on both sides
- Designed for local network / learning purposes
- Not intended for production use
- C++
- POSIX sockets
- Linux system calls
- XOR cipher (custom implementation)
- Makefile build system
This project was built to explore:
- Low-level networking in C++
- File streaming over TCP
- Manual memory management
- Basic encryption techniques
- System-level programming concepts
