commit 7bf7e39bd863021ec309b871572fc10d3ed20270 parent 6c88ca4162d8f912119e9bc3f51020c4bf72bb7b Author: Alex Balgavy <a.balgavy@gmail.com> Date: Sun, 29 Sep 2019 14:09:52 -0400 scripts for encrypting/decrypting folders Former-commit-id: d8210d2a03576878c64fdf4007175a8b4ecaea1c Diffstat:
A | scripts/decrypt-dir | | | 14 | ++++++++++++++ |
A | scripts/encrypt-dir | | | 21 | +++++++++++++++++++++ |
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/scripts/decrypt-dir b/scripts/decrypt-dir @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +if ! command -v gpg &>/dev/null; then + echo "gpg not installed." >&2 + exit 1 +fi + +if [ ! -z "$2" ]; then + mkdir -p "$2" + gpg --decrypt "$1" | tar xz -C "$2" +echo "Decrypted $1 into $2" +else + gpg --decrypt "$1" | tar xz +echo "Decrypted $1 into ./" +fi diff --git a/scripts/encrypt-dir b/scripts/encrypt-dir @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +if ! command -v gpg &>/dev/null; then + echo "gpg not installed." >&2 + exit 1 +fi + +export GPG_TTY=$(tty) + +if [ -f "$1" ]; then +elif [ -d "$1" ]; then +else + echo "File doesn't exist or not supported." +fi +if [ ! -z "$2" ]; then + mkdir -p "$2" + (cd "${1%/*}" && tar cz "${1##*/}") | gpg -c --cipher-algo aes256 -o "${2%/}"/"${1##*/}.tgz.gpg" + echo "Encrypted $1 into $2" +else + (cd "${1%/*}" && tar cz "${1##*/}") | gpg -c --cipher-algo aes256 -o "${1##*/}.tgz.gpg" + echo "Encrypted $1 into ." +fi