From ca8955bc35e0774b20c316d2109eaf2be00c435c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 23 May 2018 20:08:28 +0800 Subject: Update cli/gpg-aes256.sh --- cli/gpg-aes256.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/gpg-aes256.sh b/cli/gpg-aes256.sh index 9ce610b..988a85a 100755 --- a/cli/gpg-aes256.sh +++ b/cli/gpg-aes256.sh @@ -1,9 +1,8 @@ #!/bin/sh # -# Encrypt the given file using symmetric AES256 algorithm. +# Copyright (c) 2015,2018 Aaron LI # -# Aaron LI -# 2015-01-24 +# Encrypt a file using GPG with symmetric AES256 algorithm. # case "$1" in @@ -13,7 +12,17 @@ case "$1" in ;; esac +if which gpg2 >/dev/null 2>&1; then + GPG=gpg2 +elif which gpg >/dev/null 2>&1; then + GPG=gpg +else + echo "ERROR: cannot find gpg/gpg2!" + exit 2 +fi + infile="$1" outfile="${infile}.gpg" -gpg2 --symmetric --cipher-algo aes256 -o "${outfile}" "${infile}" +${GPG} --symmetric --cipher-algo aes256 -o "${outfile}" "${infile}" chmod 0600 "${outfile}" +echo "Encrypted file saved to: ${outfile}" -- cgit v1.2.2