Skip to content

Instantly share code, notes, and snippets.

@d0c-s4vage
Created January 27, 2017 00:47
Show Gist options
  • Save d0c-s4vage/949d82b2a5a9ead306ff5a488bb21ef1 to your computer and use it in GitHub Desktop.
Save d0c-s4vage/949d82b2a5a9ead306ff5a488bb21ef1 to your computer and use it in GitHub Desktop.
function aes_encrypt {
(
source ~/.aes.sh >/dev/null 2>&1
test -t 0 >/dev/null 2>&1
if [ $? -eq 0 ] ; then
decrypted="$1"
encrypted="$decrypted".enc
openssl enc -in "$decrypted" -out "$encrypted" -e -aes256 -k "$AES_KEY"
else
openssl enc -e -aes256 -k "$AES_KEY"
fi
)
}
function aes_decrypt {
(
source ~/.aes.sh >/dev/null 2>&1
test -t 0 >/dev/null 2>&1
if [ $? -eq 0 ] ; then
encrypted="$1"
decrypted="${encrypted%.*}"
openssl enc -in "$encrypted" -out "$decrypted" -d -aes256 -k "$AES_KEY"
else
openssl enc -d -aes256 -k "$AES_KEY"
fi
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment