Skip to content

JonathanCrider/encrypt-decrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightweight CLI Tool for Encryption and Decryption

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)

Future Improvements

In the future, I plan to

  • Add compatibility support for other shells (e.g., Bash) by dynamically detecting shells in install.sh and uninstall.sh
  • Enhance error handling for edge cases like missing dependencies (openssl, curl) or invalid arguments
  • Unit tests

Installation

⚠️ NOTE: This script was written on MacOS running zsh, so you may need to modify the code to run in your specific environment.

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

Usage

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:

  1. Input File Path: The full path (or relative path) to the original input file you want to encrypt or decrypt.
  2. Output File Path: The full path (or relative path) to where the resulting encrypted or decrypted file should be saved.

Examples

# 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

Uninstall

Run the following command to uninstall the script:

curl -sSL https://raw.githubusercontent.com/JonathanCrider/encrypt-decrypt/main/uninstall.sh | zsh

🤝 Contributing

If you'd like to contribute, please fork the repository and open a pull request to the main branch.

About

Installable bash CLI tool to quickly encrypt and decrypt a file using openssl/aes

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages