Skip to content

File Encryptor is a command-line tool written in Go that provides secure file encryption and decryption using either SSH / RSA key pairs or password-based encryption.

License

Notifications You must be signed in to change notification settings

sd416/file-encryptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

64 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

File Encryptor

File Encryptor is a powerful command-line tool written in Go that provides secure file encryption and decryption using either RSA key pairs or password-based encryption. It features a modern web UI and supports all file types, including text files, media files, and office documents.

Features

Core Encryption Features

  • Encrypt files using RSA public keys or passwords
  • Decrypt files using RSA private keys or passwords
  • Hybrid encryption: RSA for key exchange, AES for file content
  • Support for both PEM and OpenSSH format keys
  • Automatically preserve and restore the original file extensions
  • Support for all file types: text, images, videos, spreadsheets, and more
  • Concurrent processing with worker pool for faster encryption and decryption of multiple files
  • Graceful cancellation with timeout support and signal handling (Ctrl+C)

Web UI Features

  • Modern web interface with drag-and-drop file support
  • Real-time progress tracking and status updates
  • Responsive design for desktop, tablet, and mobile devices
  • Dark/light theme toggle with preference persistence
  • Batch file operations with drag & drop
  • RSA key pair generation directly in the browser
  • Secure REST API with CORS support and security headers
  • Single binary deployment with embedded web assets

Installation

Docker (Recommended)

The easiest way to use File Encryptor is with Docker:

# Pull the latest image
docker pull ghcr.io/sd416/file-encryptor:latest

# Encrypt a file
docker run --rm -v $(pwd):/data ghcr.io/sd416/file-encryptor:latest -e -f myfile.txt -p "mypassword"

# Decrypt a file
docker run --rm -v $(pwd):/data ghcr.io/sd416/file-encryptor:latest -d -f myfile.txt.enc -p "mypassword"

πŸ“– See DOCKER.md for complete Docker usage guide

Build from Source

Prerequisites

  • Go 1.23 or later
  • Git

Steps

  1. Clone this repository:

    git clone https://github.com/sd416/file-encryptor.git
    cd file-encryptor
  2. Build the CLI version:

    make build
  3. Build with Web UI support:

    make build-web

Usage

Web UI Mode

Start the web server:

# Start web UI on default port 8080
./bin/file-encryptor-web --web

# Start on custom port
./bin/file-encryptor-web --web --web-port 9000

# Start with HTTPS
./bin/file-encryptor-web --web --web-tls --cert-file cert.pem --key-file key.pem

Then open your browser to http://localhost:8080 for the web interface.

Web UI Features:

  • Drag & Drop: Simply drag files onto the interface
  • Encrypt/Decrypt: Choose password or key file authentication
  • Generate Keys: Create RSA key pairs and download them
  • Progress Tracking: Real-time status updates
  • Theme Toggle: Switch between dark and light modes
  • Mobile Friendly: Responsive design for all devices

Command Line Interface

Key Generation

# Generate RSA key pair
./bin/file-encryptor --generate-keys

# Generate keys with custom name
./bin/file-encryptor --generate-keys --key-name mykey

# Generate and encrypt in one step
./bin/file-encryptor --generate-keys -e -f document.pdf

Encryption

Using RSA public key:

./bin/file-encryptor -e --file picture.jpg --key my_ssh_key.pub
# Output: picture.jpg.enc

Using password:

./bin/file-encryptor -e --file document.pdf --password myStrongPassword123
# Output: document.pdf.enc

Multiple files:

./bin/file-encryptor -e --password myPassword123 --file file1.txt file2.jpg file3.pdf

Decryption

Using RSA private key:

./bin/file-encryptor -d --file picture.jpg.enc --key my_ssh_key
# Output: picture.jpg (original extension restored)

Using password:

./bin/file-encryptor -d --file document.pdf.enc --password myStrongPassword123
# Output: document.pdf

Advanced Options

Set operation timeout:

./bin/file-encryptor -e -f large_file.mp4 -p myPassword --timeout 10m

Verbose logging:

./bin/file-encryptor -e -f file.txt -p password --verbose

Configuration file:

./bin/file-encryptor -e -f file.txt -p password --config custom-config.yaml

Development

Build Targets

make build          # Build CLI version
make build-web      # Build with web UI
make test           # Run tests
make lint           # Run linters
make clean          # Clean build artifacts
make dev-setup      # Setup development environment

Project Structure

file-encryptor/
β”œβ”€β”€ cmd/file-encryptor/     # Main application
β”œβ”€β”€ pkg/                    # Core packages
β”‚   β”œβ”€β”€ crypto/            # Encryption logic
β”‚   β”œβ”€β”€ logging/           # Logging utilities
β”‚   └── webapi/            # Web API components
β”œβ”€β”€ web/                   # Web UI assets
β”‚   β”œβ”€β”€ templates/         # HTML templates
β”‚   └── static/           # CSS, JS, images
β”œβ”€β”€ Makefile              # Build automation
└── README.md            # This file

Security

Encryption Standards

  • AES-256-GCM for file encryption (authenticated encryption)
  • RSA-4096 for key exchange (configurable key size)
  • PBKDF2 with SHA-256 for password-based key derivation
  • HMAC-SHA-256 for integrity verification
  • Secure random number generation for all cryptographic operations

Web Security

  • CORS Protection with configurable origins
  • Security Headers (CSP, HSTS, X-Frame-Options)
  • File Size Limits to prevent DoS attacks
  • Path Traversal Protection for static file serving
  • HTTPS Support with TLS 1.2+ enforcement

Best Practices

  • Always use strong, unique passwords (12+ characters)
  • Keep private keys secure and never share them
  • Use HTTPS in production environments
  • Regularly update to the latest version
  • Backup important files before encryption

Supported File Types

The tool supports all file types, including:

  • Text: TXT, CSV, JSON, XML, YAML
  • Images: JPG, PNG, GIF, BMP, TIFF, SVG
  • Videos: MP4, AVI, MOV, MKV, WebM
  • Audio: MP3, WAV, FLAC, AAC
  • Documents: PDF, DOCX, XLSX, PPTX
  • Archives: ZIP, TAR, 7Z, RAR
  • Code: JS, Python, Go, Java, C++
  • Any other binary or text file

Contributing

Contributions are welcome! Please:

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

Development Guidelines

  • Follow Go best practices and conventions
  • Add tests for new functionality
  • Update documentation as needed
  • Ensure all tests pass before submitting

License

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

Disclaimer

This tool is provided as-is, without any warranties. Always ensure you have backups of your important files before encryption. Test the tool with non-critical files first to ensure it meets your requirements.

Support

  • Documentation: Check this README and inline help (--help)
  • Issues: Report bugs via GitHub Issues
  • Feature Requests: Submit enhancement ideas via GitHub Issues
  • Security: Report security issues privately via email

About

File Encryptor is a command-line tool written in Go that provides secure file encryption and decryption using either SSH / RSA key pairs or password-based encryption.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •