Skip to content

A secure file encryption and text encoding server with web interface and admin tools. Built with Flask (Python) and Rust client.

License

Notifications You must be signed in to change notification settings

serbekun/hash_server

Repository files navigation

Hash Server πŸ”’

A secure file encryption and text encoding server with web interface and admin tools. Built with Flask (Python) and Rust client.

Features ✨

  • File Encryption/Decryption - XOR cipher with password protection
  • Base64 Encoding - Text encoding/decoding via web interface
  • Secure File Upload - Path traversal protection and file validation
  • Token-based Authentication - Secure admin and download access
  • Web Interface - User-friendly web UI for all operations
  • Admin Dashboard - Server management and monitoring
  • Cross-platform Clients - Python and Rust admin clients
  • Comprehensive Logging - Detailed server activity logs

Quick Start πŸš€

Prerequisites

  • Python 3.8+
  • Rust (for admin client)
  • Flask

Installation

  1. Clone the repository
git clone https://github.com/serbekun/hash-server.git
cd hash-server
  1. Install Python dependencies
pip install -r requirements.txt
  1. Configure server settings
# Edit url_info.py
_IP = "your_server_ip"  # Use "127.0.0.1" for local development
_PORT = 2222
  1. Run the server
python server.py

The server will start at http://your_server_ip:2222

Usage πŸ“–

Web Interface

  • Main Page: http://your_server_ip:2222/
  • File Encryption: http://your_server_ip:2222/hashing_file
  • Base64 Tools: http://your_server_ip:2222/hashing_text_base64

File Encryption

  1. Upload any file through the web interface
  2. Set encryption password (minimum 4 characters)
  3. Choose encrypt/decrypt mode
  4. Download processed file using provided token

Admin Access

Python Client

python admin_client.py

Available commands: admin, clear_uploads, list_uploads, log

Rust Client

cd admin_client
cargo run

Available commands: admin, clear_uploads, list_uploads, log, set_token

API Documentation πŸ”§

File Processing

POST /hashing_file/process_file
Content-Type: multipart/form-data

file: [file]
password: [string]
mode: encrypt|decrypt

Base64 Encoding

POST /base64
Content-Type: application/json

{
  "text": "string",
  "mod": "1"  // 1=encode, 2=decode
}

Admin Endpoints

All admin endpoints require valid token in JSON body:

{"token": "admin_your_token_here"}

Project Structure πŸ—‚οΈ

hash_server/
β”œβ”€β”€ server.py                 # Main server
β”œβ”€β”€ config.py                # Configuration
β”œβ”€β”€ routes/                  # Flask blueprints
β”‚   β”œβ”€β”€ admin_routes/
β”‚   └── process_file/
β”œβ”€β”€ templates/               # Web interfaces
β”‚   β”œβ”€β”€ main/
β”‚   β”œβ”€β”€ hashing_file/
β”‚   └── hashing_text_base64/
β”œβ”€β”€ admin_client/            # Rust admin client
β”‚   └── src/
β”œβ”€β”€ tokens/                  # Token storage
β”œβ”€β”€ uploads/                 # Temporary file storage
└── log/                     # Server logs

Security Features πŸ›‘οΈ

  • Path Traversal Protection - Secure filename validation
  • Token Authentication - Time-limited access tokens
  • File Size Limits - 50MB maximum file size
  • Input Validation - Comprehensive form validation
  • Secure File Handling - Automatic temp file cleanup

Configuration βš™οΈ

Server Settings (config.py)

class Config:
    class Link:
        HOST = "localhost-for_example"  # Server IP
        PORT = 2222           # Server port
    
    class FileManaging:
        LEAVE_UPLOADED_FILE = False  # Auto-cleanup

Environment Variables

For production, use environment variables:

export SERVER_IP="your_ip"
export SERVER_PORT="2222"

Development πŸ› οΈ

Adding New Features

  1. Create new blueprint in routes/
  2. Add routes in server.py
  3. Update admin client if needed

Testing

# Test file encryption
python -c "from XORFileCipher import encrypt_file, decrypt_file; print('Cipher test passed')"

# Test server endpoints
python client.py

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing 🀝

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support πŸ’¬

For support and questions:

  • Open an issue on GitHub
  • Check the documentation in code comments

Note: This server is designed for secure internal networks. For production use, consider additional security measures like HTTPS, rate limiting, and firewall configuration.

About

A secure file encryption and text encoding server with web interface and admin tools. Built with Flask (Python) and Rust client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published