Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Created April 26, 2016 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacaetevha/0fe5353651a44b45f4ca5755599ae52b to your computer and use it in GitHub Desktop.
Save jacaetevha/0fe5353651a44b45f4ca5755599ae52b to your computer and use it in GitHub Desktop.
BASH script to en-/decrypt a file with GPG
#!/bin/bash
if [ "$1" == "--encode" ]
then
FILE=${2:-private.tar}
gpg --output $FILE.enc --symmetric --cipher-algo AES256 $FILE
elif [ "$1" == "--decode" ]
then
FILE=${2:-private.tar.enc}
FILE_BASENAME=$(basename ${FILE%.*})
gpg --output $FILE_BASENAME --decrypt $FILE
else
echo "$0 [--encode | --decode]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment