Last active
August 24, 2018 07:59
-
-
Save pstaender/cb08324afe8a0a5ad4a72c7269a4611e to your computer and use it in GitHub Desktop.
Crypt and Decrypt gzipped tar files in bash
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
function tarcrypt { | |
file=$1 | |
filename="$file.tar.gz.enc" | |
if [ -f $file ]; then | |
echo "-> $filename" | |
tar cz $file | openssl enc -aes-256-cbc -e > $filename | |
elif [ -d $file ]; then | |
echo "-> directory $filename" | |
# display progress | |
# linux: tar cf - $file -P | pv -s $(du -sb $file | awk '{print $1}') | gzip > big-files.tar.gz | |
tar cf - $file -P | pv -s $(($(du -sk $file | awk '{print $1}') * 1024)) | openssl enc -aes-256-cbc -e > $filename | |
fi | |
} | |
function tardecrypt { | |
file=$1 | |
openssl aes-256-cbc -d -in $file | tar xz | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment