File Encryptor is a command-line tool written in Go that provides secure file encryption and decryption using either RSA key pairs or password-based encryption. It now supports all file types, including text files, media files (e.g., images, videos), and office documents (e.g., XLS, DOCX, PDF).
- 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
- Detailed logging for transparency and debugging
- Support for all file types: text, images (JPG, PNG), videos, spreadsheets, and more
- Parallel processing for faster encryption and decryption of large files
-
Ensure you have Go installed on your system (version 1.16 or later).
- Verify with:
go version
- Verify with:
-
Clone this repository:
git clone https://github.com/yourusername/file-encryptor.git
-
Navigate to the project directory:
cd file-encryptor
-
Build the project:
go build -o file-encryptor main.go
To generate an RSA key pair (private and public key) in your current folder:
ssh-keygen -t rsa -b 4096 -f my_ssh_key
- This creates
my_ssh_key
(private key) andmy_ssh_key.pub
(public key).
./file-encryptor -e --file <input_file> --key my_ssh_key.pub
Example:
./file-encryptor -e --file picture.jpg --key my_ssh_key.pub
- The encrypted file will be saved as
picture.jpg.enc
.
./file-encryptor -e --file <input_file> --password <your_password>
Example:
./file-encryptor -e --file document.pdf --password myStrongPassword123
./file-encryptor -d --file <encrypted_file> --key my_ssh_key
Example:
./file-encryptor -d --file picture.jpg.enc --key my_ssh_key
- The decrypted file will retain its original extension (e.g.,
picture.jpg
).
./file-encryptor -d --file <encrypted_file> --password <your_password>
Example:
./file-encryptor -d --file document.pdf.enc --password myStrongPassword123
- Always use strong, unique passwords for password-based encryption.
- Keep your private keys secure and never share them.
- This tool uses:
- AES-256 for file encryption (symmetric encryption).
- RSA for secure key exchange (asymmetric encryption).
- PBKDF2 for key derivation in password-based encryption.
- HMAC for integrity verification.
- File extensions are preserved automatically during encryption and restored after decryption.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is provided as-is, without any warranties. Always ensure you have backups of your important files before encryption.
File Support Note:
- The tool supports all file types, including:
- Text: TXT, CSV, JSON
- Media: JPG, PNG, MP4
- Documents: DOCX, PDF, XLS
- Others: Any other binary file format.
Example usage ensures seamless encryption and decryption without data corruption.