Skip to content

Hibar3/rust-file-encryptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Encryptor CLI - Made with Rust

A secure, production-quality CLI tool for encrypting and decrypting files using modern cryptography (AES-256-GCM / ChaCha20-Poly1305 and Argon2id).

🚀 Installation

Prerequisites

Before installing, ensure you have the following tools installed on your Windows machine:

  1. Rust: Install Rust.
  2. C++ Build Tools: Required for compiling some dependencies.

Option 1: Run from Source (Dev)

If you have the source code, you can run it directly via Cargo:

# Run CLI commands
cargo run --release -- encrypt input.txt output.enc

# Run TUI mode
cargo run --release -- ui

Option 2: Install Globally (Recommended)

To use rust-file-encryptor from anywhere in your terminal:

  1. Install via Cargo:

    cargo install --path .

    This will compile and move the binary to your Cargo bin folder (usually %USERPROFILE%\.cargo\bin), which should already be in your PATH.

  2. Manual Installation:

    • Locate the built executable at: target\release\rust-file-encryptor.exe
    • Copy it to a folder in your PATH (e.g., C:\Windows\System32 or a custom bin folder).

📖 Usage

🖥️ Interactive TUI Mode (New!)

Launch the terminal user interface for a more visual experience.

rust-file-encryptor ui

Controls:

  • Arrows / Tab: Navigate fields and tabs.
  • Enter: Select files (in picker) or Submit forms.
  • Esc: Go back or Cancel.
  • Features: File picker, password masking, and easy switching between Encrypt/Decrypt modes.

Encrypt a File (CLI)

Encrypts a file using a password. If the password is not provided via flag, you will be securely prompted.

rust-file-encryptor encrypt <INPUT_FILE> <OUTPUT_FILE> [FLAGS]

Flags:

  • -p, --password <PASSWORD>: Provide password directly (less secure in history).
  • -a, --algorithm <ALGO>: Choose encryption algorithm.
    • aes256-gcm (Default) - Hardware accelerated, very fast.
    • chacha20-poly1305 - fast in software, safe against timing attacks.
  • --overwrite: Overwrite the output file if it exists.

Examples:

# Interactive password prompt (Recommended)
rust-file-encryptor encrypt secret.doc secret.enc

# Using ChaCha20-Poly1305
rust-file-encryptor encrypt image.png image.enc --algorithm chacha20-poly1305

# Force overwrite
rust-file-encryptor encrypt data.csv data.enc --overwrite

Decrypt a File (CLI)

Decrypts a file back to its original form.

rust-file-encryptor decrypt <INPUT_FILE> <OUTPUT_FILE> [FLAGS]

Examples:

# Interactive password prompt
rust-file-encryptor decrypt secret.enc secret_restored.doc

# Provide password (useful for scripts)
rust-file-encryptor decrypt backup.enc backup.tar.gz --password "MySecretPass"

🔒 Security Details

  • Encryption: Authenticated Encryption with Associated Data (AEAD).
    • AES-256-GCM (96-bit nonce, 128-bit tag)
    • ChaCha20-Poly1305 (96-bit nonce, 128-bit tag)
  • Key Derivation: Argon2id
    • Resists GPU/ASIC brute-force attacks.
    • Uses a unique random 32-byte salt for every file.
  • Randomness: Uses OsRng (cryptographically secure system RNG) for salts and nonces.
  • Memory Safety: Passwords are zeroed out from memory after use.

⚠️ Disclaimer

This tool is provided as-is. While it uses standard, well-audited cryptographic primitives, always ensure you have backups of your important data.

About

File encryptor CLI tool made with Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages