-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·141 lines (110 loc) · 3.74 KB
/
test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash -eux
go build -o rsaconfigcipher decrypt_files.go
./rsaconfigcipher *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher *.rsa -v
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher *.rsa --verbose
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher -v *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --verbose *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --verbose *.rsa -p keys/rsakey.pem.pub
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --verbose *.rsa -P keys/rsakey.pem
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --verbose *.rsa -p keys/rsakey.pem.pub -P keys/rsakey.pem
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher -p keys/rsakey.pem.pub *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher -P keys/rsakey.pem *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher -p keys/rsakey.pem.pub -P keys/rsakey.pem *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --public-key-path keys/rsakey.pem.pub *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --private-key-path keys/rsakey.pem *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher --public-key-path keys/rsakey.pem.pub --private-key-path keys/rsakey.pem *.rsa
md5sum -c .md5checksum
rm -rf example_config.{yml,php}
./rsaconfigcipher -h
./rsaconfigcipher --help
./rsaconfigcipher --version
echo "I WANT TO ENCRYPT" | ./rsaconfigcipher
echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -i
printf "I WANT TO ENCRYPT" | ./rsaconfigcipher
printf "I WANT TO ENCRYPT" | ./rsaconfigcipher -i
# validate encrypt-decrypt a string
printf "I WANT TO ENCRYPT" | ./rsaconfigcipher -s > constructed_config.txt.rsa
./rsaconfigcipher constructed_config.txt.rsa
CYPHERTEXT=$(cat constructed_config.txt)
if [ ! "$CYPHERTEXT" == "I WANT TO ENCRYPT" ]
then
echo "Error, the cypher text is not equals"
exit 1
fi
rm -rf constructed_config.txt{,.rsa}
# validate encrypt-decrypt a long text
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "$line" | ./rsaconfigcipher -s >> constructed_config.txt.rsa
done < "example_long_value.txt"
./rsaconfigcipher constructed_config.txt.rsa
if [ ! "$(md5sum constructed_config.txt | awk '{ print $1 }')" == "$(md5sum example_long_value.txt | awk '{ print $1 }')" ]
then
echo "Error, the cypher text of files is not equals"
exit 1
fi
rm -rf constructed_config.txt{,.rsa}
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -i -s)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -is)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -si)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -s)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -s -p keys/rsakey.pem.pub)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
CYPHERTEXT=$(echo "I WANT TO ENCRYPT" | ./rsaconfigcipher -is -p keys/rsakey.pem.pub)
if [ ! $(echo "$CYPHERTEXT" | egrep "^{{%rsa:.*%}}") ]
then
echo "Error, the cypher text is incorrect"
exit 1
fi
rm -rf ./rsaconfigcipher
echo "Test Complete Successfully"