Skip to content

Instantly share code, notes, and snippets.

@nickabal
Created November 6, 2014 18:28
Show Gist options
  • Save nickabal/9ea1c060022b5d36fc92 to your computer and use it in GitHub Desktop.
Save nickabal/9ea1c060022b5d36fc92 to your computer and use it in GitHub Desktop.
# Pair of script for encrypt and decrypt directories using AES
#encrypt.sh
#!/bin/bash
wd=`pwd`;
if [ -z "$1" ]; then echo "./encrypt.sh <foldername>"; exit 1; fi
indir=$1
out=$wd/
basename=$(basename $1)
echo "Enter password. Save this somewhere safe!"
read passout
echo "Encrypting to: $out$basename.tar.enc"
tar c $indir | openssl enc -aes-256-cbc -e -pass pass:$passout > $out$basename.tar.enc
###################################################
###################################################
#decrypt.sh
#!/bin/bash
wd=`pwd`;
if [ -z "$1" ]; then echo "./decrypt.sh <file.enc>"; exit 1; fi
indir=$1
out=$wd
echo "Enter password. Decrypting to: $wd/dec/"
read passin
mkdir -p $wd/dec/
openssl enc -aes-256-cbc -d -pass pass:$passin -in $indir | tar -xf - -C $wd/dec/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment