Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Encrypt files & folders for Mac & Linux
#!/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