Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Last active June 30, 2019 01:57
Show Gist options
  • Save icaoberg/d47f4098d5c281dd292866f8b2e84726 to your computer and use it in GitHub Desktop.
Save icaoberg/d47f4098d5c281dd292866f8b2e84726 to your computer and use it in GitHub Desktop.
Simple decryption script
#!/bin/bash
# Copyright (C) 2018-2019 Ivan Cao-Berg
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
if [ $# -ne 1 ]; then
echo "Simple decryption script that takes exactly one input argument."
cowsay -f tux "Example"
echo "~/bin/decrypt.sh foobar.jpg.gpg"
exit
fi
FILE=$1
if [[ "$FILE" = *"gpg"* ]]; then
gpg -d "$FILE" > "${FILE%.*}"
if [ -f "$FILE" ]; then
rm -fv "$FILE"
fi
else
echo "File "$FILE" is not encrypted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment