Last active
August 29, 2015 14:01
-
-
Save 0xBEEB/c73a4aeb688a9f6b16fb to your computer and use it in GitHub Desktop.
A simple method to keep encrypted directories in OSX. A super lightweight alternative to something like TrueCrypt.
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
#!/usr/bin/env bash | |
# dircrypt.sh | |
# Thomas Schreiber <[email protected]> | |
# Uses symmetric encryption to encrypt and decrypt directories quickly. | |
# A simple method to keep encrypted directories on OSX. A super lightweight | |
# alternative to something like TrueCrypt. | |
# Usage: | |
# To Encrypt: | |
# $ ./dircrypt.sh myDirectory | |
# To Decrypt: | |
# $ ./dircrypt.sh myDirectory.gpg | |
if [[ $1 == *.gpg ]] | |
then | |
FILEHANDLE=`echo $1| cut -d'.' -f 1` | |
gpg --output ${FILEHANDLE}.tar.gz --decrypt ${FILEHANDLE}.gpg | |
tar -zxvf ${FILEHANDLE}.tar.gz | |
srm -rf ${FILEHANDLE}.gpg | |
srm -rf ${FILEHANDLE}.tar.gz | |
else | |
FILEHANDLE=`echo $1 | rev | cut -d'/' -f 1 | rev` | |
tar -zcvf $1.tar.gz ${FILEHANDLE} | |
gpg --output ${FILEHANDLE}.gpg --symmetric ${FILEHANDLE}.tar.gz | |
srm -rf $1.tar.gz | |
srm -rf $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment