Last active
December 8, 2015 23:34
-
-
Save epappas/2c929665bb994251e771 to your computer and use it in GitHub Desktop.
Encrypt files & folders for Mac & Linux
This file contains 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/sh | |
# | |
# This is a free to use, free to restribute, | |
# free to fork and free to edit software. | |
# | |
# No responsibility is granted for its use | |
# | |
# Contributors: | |
# - Evangelos Pappas <epappas@evalonlabs.com> | |
# | |
# Enjoy! | |
DRY_MODE=0 | |
ENCR_MODE=1 | |
DECR_MODE=0 | |
CIPHER=aes-256-cbc | |
set -e | |
run_main(){ | |
if [ $ENCR_MODE -ne 0 ]; then | |
tar -cf - ${FILE_IN} | openssl ${CIPHER} -salt -out ${FILE_IN}.tar.aes | |
else | |
openssl ${CIPHER} -d -salt -in ${FILE_IN} | tar -x -f - | |
fi | |
} | |
if [ $# -eq 0 ]; then | |
exit 0 | |
fi | |
if [ ! -z "$(echo $@ | grep -e "--decrypt")" ]; then | |
shift | |
ENCR_MODE=0 | |
DECR_MODE=1 | |
fi | |
FILE_IN=$1 | |
run_main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment