#!/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