diff options
author | Aaron LI <aly@aaronly.me> | 2018-05-23 20:08:28 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-05-23 20:08:28 +0800 |
commit | ca8955bc35e0774b20c316d2109eaf2be00c435c (patch) | |
tree | b40d0d82905d4f0b8578d7af5832efb170a9d062 | |
parent | e12c4928dc71f3de2f5568bccfd9e0b9dfb5ac09 (diff) | |
download | atoolbox-ca8955bc35e0774b20c316d2109eaf2be00c435c.tar.bz2 |
Update cli/gpg-aes256.sh
-rwxr-xr-x | cli/gpg-aes256.sh | 17 |
1 files changed, 13 insertions, 4 deletions
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}" |