Created
September 29, 2015 22:54
-
-
Save cmivxx/3fab5e8782d52322cdff to your computer and use it in GitHub Desktop.
Simple shell script for OSX to encrypt and decrypt files easily.
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
| #!/bin/bash | |
| ############################################################# | |
| # OpenSSL Encryption script written by: | |
| # Chris Miller | |
| # chris@intellagentbenefits.com | |
| usage(){ | |
| echo "$(tput bold)Usage:$(tput sgr0) $0 enc file_name.txt" | |
| echo "$(tput bold)Usage:$(tput sgr0) $0 unenc file_name.txt" | |
| } | |
| ############################################################# | |
| # Show usage instructions | |
| # call usage() function if flag/argument not supplied | |
| # [[ $# -eq 0 ]] && usage | |
| if [[ $1 = "enc" ]] | |
| then | |
| echo "encrypting..." | |
| openssl enc -aes-256-cbc -a -in $PWD/$2 -out $PWD/$2.enc | |
| echo "encrypted" | |
| elif [[ $1 = "unenc" ]] | |
| then | |
| echo "unencrypting..." | |
| openssl enc -d -aes-256-cbc -a -in $PWD/$2 -out $PWD/$2.txt | |
| ############################################################## | |
| # Show Help and Usage Instructions | |
| elif [[ $1 = "help" && $2 = "" ]] | |
| then | |
| usage | |
| elif [[ $1 = "" && $2 = "" ]] | |
| then | |
| usage | |
| ############################################################## | |
| # Show Bad Command Error & Usage Instructions | |
| else | |
| echo "$1 $2: Bad Command" | |
| echo " " | |
| usage | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment