This project began as a simple way to encrypt sensitive files while experimenting with shell scripting. It combines my interest in security with the need for efficiency in everyday tasks.
The tool enables you to encrypt and decrypt files from the command line using openssl with AES-256-CBC encryption, PBKDF2 key derivation, and a salt for added security. It's designed as a secure but lightweight solution for sharing sensitive files—just be sure to follow password and security best practices! (I make no promises or guarantees)
In the future, I plan to
- Add compatibility support for other shells (e.g., Bash) by dynamically detecting shells in
install.sh
anduninstall.sh
- Enhance error handling for edge cases like missing dependencies (openssl, curl) or invalid arguments
- Unit tests
Run the following command in your terminal to install the functions and create sourcing in your .zshrc
file:
Feel free to check the install.sh
file before you use this.
curl -sSL https://raw.githubusercontent.com/JonathanCrider/encrypt-decrypt/main/install.sh | zsh
After installation, be sure to open a new terminal or refresh your .zshrc
using the following command:
source ~/.zshrc
Pro tip: add an alias (shortcut) for refreshing your terminal.
Copy/paste the command below to add the alias to your .zshrc
file. You will need to run the command above to use it the first time, or open a new terminal.
echo -e "\n# ALIAS to refresh terminal\nalias refresh='source ~/.zshrc'" >> ~/.zshrc
Once the code is saved and available (you may need to refresh or open a new terminal window), you have 2 commands:
encrypt
decrypt
They both take 2 arguments:
- Input File Path: The full path (or relative path) to the original input file you want to encrypt or decrypt.
- Output File Path: The full path (or relative path) to where the resulting encrypted or decrypted file should be saved.
# any directory
encrypt ~/path/to/originalfile.txt ~/path/to/encryptedfile.txt
# same directory
encrypt test.txt test-encrypted.txt
# any directory
decrypt ~/path/to/encryptedfile.txt ~/path/to/decryptedfile.txt
# same directory
decrypt test-encrypted.txt test-decrypted.txt
Run the following command to uninstall the script:
curl -sSL https://raw.githubusercontent.com/JonathanCrider/encrypt-decrypt/main/uninstall.sh | zsh
If you'd like to contribute, please fork the repository and open a pull request to the main
branch.