dotfiles/bin/gpe
2021-05-16 12:13:21 +03:00

22 lines
410 B
Bash
Executable file

#!/usr/bin/env bash
# For working this script set $GPG_KEY with gpg key
## Functions
encrypt() {
gpg -ea -r $GPG_KEY $@
}
decrypt() {
local f="$1"
if [ ${f: -4} == ".asc" ]
then gpg -d -o ${f%%.asc} $@
elif [ ${f: -4} == ".gpg" ]
then gpg -d -o ${f%%.gpg} $@
fi
}
## Case's
case "$1" in
enc|e) shift; encrypt $@ ;;
dec|d) shift; decrypt $@ ;;
*) echo "Error." ;;
esac