Skip to content

Instantly share code, notes, and snippets.

@ranaroussi
Created August 29, 2016 20:20
Show Gist options
  • Select an option

  • Save ranaroussi/022b89d235b0ed7bf236e7b68926310e to your computer and use it in GitHub Desktop.

Select an option

Save ranaroussi/022b89d235b0ed7bf236e7b68926310e to your computer and use it in GitHub Desktop.
openssl encrypt/decrypt shortcuts (for .bashrc/.bash_aliases)
# encrypt/descrupy
encrypt(){
if [ -z "$1" ]
then
echo "Missing argument: Use encrypt [in] [out]"
else
if [ -z "$2" ]
then
cp $1 /tmp/$1
openssl enc -aes-256-cbc -e -in /tmp/$1 -out $1
rm -f /tmp/$1 2> /dev/null
else
openssl enc -aes-256-cbc -e -in $1 -out $2
fi
fi
}
alias enc=encrypt
decrypt(){
if [ -z "$1" ]
then
echo "Missing argument: Use decrypt [in] [out]"
else
if [ -z "$2" ]
then
cp $1 /tmp/$1
openssl enc -aes-256-cbc -d -in /tmp/$1 -out $1
rm -f /tmp/$1 2> /dev/null
else
openssl enc -aes-256-cbc -d -in $1 -out $2
fi
fi
}
alias dec=decrypt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment