-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkEnc.sh
executable file
·52 lines (39 loc) · 1.26 KB
/
checkEnc.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
#!/bin/bash
if [ ! -r message.txt ]; then
printf '%s\n' 'No message to encrypt. Create a file named message.txt to start.'
exit 1
fi
echo "ENCRYPTION"
echo "----------"
sslstart=$(date +%s%N)
openssl aes-128-ecb -e -nosalt -K "54686973206973206d79206b65792121" -in message.txt -out OpenSSLcypher.txt
sslfinish=$(date +%s%N)
mystart=$(date +%s%N)
python client.py message.txt enc > Mycypher.txt
myfinish=$(date +%s%N)
echo openssl timing $[$[$sslfinish/1000000]-$[$sslstart/1000000]]ms
echo my implementation timing $[$[$myfinish/1000000]-$[$mystart/1000000]]ms
sleep 2
if ! diff OpenSSLcypher.txt Mycypher.txt; then
printf '%s\n' 'Ciphers differ!'
else
printf '%s\n' 'Cyphers identical!'
fi
sleep 2
echo
echo "DECRYPTION"
echo "----------"
sslstart=$(date +%s%N)
openssl aes-128-ecb -d -nosalt -K "54686973206973206d79206b65792121" -in OpenSSLcypher.txt -out SSLplain.txt
sslfinish=$(date +%s%N)
mystart=$(date +%s%N)
python client.py Mycypher.txt dec> Myplain.txt
myfinish=$(date +%s%N)
echo openssl timing $[$[$sslfinish/1000000]-$[$sslstart/1000000]]ms
echo my implementation timing $[$[$myfinish/1000000]-$[$mystart/1000000]]ms
sleep 2
if ! diff SSLplain.txt Myplain.txt; then
printf '%s\n' 'Plaintexts differ!'
else
printf '%s\n' 'Plaintexts identical!'
fi