Created
February 21, 2021 01:15
-
-
Save juanino/4f990aa63093a20de035e9487ec4638a to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
#encrypt files with aes-256-cbc cipher using openssl | |
# taken from https://superuser.com/questions/370388/simple-built-in-way-to-encrypt-and-decrypt-a-file-on-a-mac-via-command-line/370412 | |
# with minor modifications | |
#encrypt files | |
if [[ $1 == "-e" ]]; | |
then | |
if [ -f "$2" ]; | |
then | |
openssl aes-256-cbc -a -e -salt -in "$2" -out "$2.aes" | |
else | |
echo "This file does not exist!" | |
fi | |
#decrypt files | |
elif [[ $1 == "-d" ]]; | |
then | |
if [ -f "$2" ]; | |
then | |
openssl aes-256-cbc -a -d -salt -in "$2" -out "$2.decrypt" | |
else | |
echo "This file does not exist!" | |
fi | |
#show help | |
elif [[ $1 == "--help" ]]; | |
then | |
echo "This software uses openssl for encrypting files with the aes-256-cbc cipher" | |
echo "Usage for encrypting: ./encrypt -e [file]" | |
echo "Usage for decrypting: ./encrypt -d [file]" | |
else | |
echo "This action does not exist!" | |
echo "Use ./encrypt --help to show help." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment