Last active
March 1, 2022 15:15
-
-
Save gilbertfrancois/f608c5cc70686e4fbee5224694c34cc9 to your computer and use it in GitHub Desktop.
Shell functions to easily encrypt and decrypt files using AES256-CBC with openssl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add `source enc.sh` to your .bashrc, .profile or .zshrc to include these functions. | |
# | |
# For encryption, type: | |
# $ enc myfile | |
# | |
# For decryption, type: | |
# $ dec myfile.enc | |
function enc() { | |
if [ $# -eq 0 ]; then | |
echo "example: " | |
echo " enc myfile.tar.gz" | |
else | |
openssl enc -aes-256-cbc -pbkdf2 -e -in ${1} -out ${1}.enc | |
fi | |
} | |
function dec() { | |
if [ $# -eq 0 ]; then | |
echo "example: " | |
echo " dec myfile.tar.gz.enc" | |
else | |
filename=${1} | |
filename_noext=${filename%.*} | |
extension=${filename##*.} | |
openssl enc -aes-256-cbc -pbkdf2 -d -in ${filename} -out ${filename_noext} | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment