Created
August 29, 2016 20:20
-
-
Save ranaroussi/022b89d235b0ed7bf236e7b68926310e to your computer and use it in GitHub Desktop.
openssl encrypt/decrypt shortcuts (for .bashrc/.bash_aliases)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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