-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssl.sh
executable file
·37 lines (31 loc) · 977 Bytes
/
ssl.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#Encrypt/decrypt file using 256-bit Advanced Encryption Standard-Cipher Block Chaining with help of the openSSL library
#Make script executable using <chmod +x ssl.sh>
#Execute script using <./ssl.sh e | d in_file out_file>
#Parse filename and fileextensions
function parse {
fullfile=$2
filename=$(basename "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
}
if [ $1 == "e" ] # encrypt specify input and output
then
openssl aes-256-cbc -in "$2" -out "$3"
fi
if [ $1 == "d" ] # decrypt specify input and output
then
openssl aes-256-cbc -d -in "$2" -out "$3"
fi
if [ $1 == "fe" ] # encrypt folder <./ssl.sh fe IN_FOLDER ENC_FOLDER>
then
tar -c "$2" > ssl_temp;
openssl aes-256-cbc -in ssl_temp -out "$3";
rm ssl_temp
fi
if [ $1 == "fd" ] # decrypt folder <./ssl.sh fd ENC_FOLDER>
then
openssl aes-256-cbc -d -in "$2" -out ssl_temp;
tar -xf ssl_temp;
rm ssl_temp
fi