-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto.sh
More file actions
executable file
·25 lines (20 loc) · 844 Bytes
/
crypto.sh
File metadata and controls
executable file
·25 lines (20 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
usage="$(basename "$0") <options> -- Encrypt or decrypt files in the .confidential/ directory
where <options>:
-E, --encrypt \t encrypt all files in .confidential/ and output confidential.tar.gz.gpg
-D, --decrypt \t decrypt confidential.tar.gz.gpg and place files in .confidential/
-C, --clean \t delete files in ./confidential"
if [[ ! -d ".confidential" ]]; then
mkdir .confidential
fi
if [[ ( "$1" = "-E" ) || ( "$1" = "--encrypt" ) ]]; then
tar czvpf - -C .confidential . | gpg --symmetric --cipher-algo aes256 -o confidential.tar.gz.gpg
elif [[ ( "$1" = "-D" ) || ( "$1" = "--decrypt" ) ]]; then
cd .confidential
gpg -d ../confidential.tar.gz.gpg | tar xzvf -
elif [[ ( "$1" = "-C" ) || ( "$1" = "--clean" ) ]]; then
rm .confidential/*
else
echo -e "Invalid option\n${usage}"
fi
exit