Skip to content

Commit 5291172

Browse files
committed
updating
1 parent c0d04ec commit 5291172

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

hash_values

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Mean MD5 --- 3.0146601359 seconds ---
2+
Min MD5 --- 2.80683398247 seconds ---
3+
Max MD5 --- 3.2793431282 seconds ---
4+
Var MD5 --- 0.0126338724312 seconds ---
5+
DP MD5 --- 0.112400500138 seconds ---
6+
Mean SHA1 --- 3.02388672829 seconds ---
7+
Min SHA1 --- 2.85973000526 seconds ---
8+
Max SHA1 --- 3.34804487228 seconds ---
9+
Var SHA1 --- 0.0103539825013 seconds ---
10+
DP SHA1 --- 0.10175452079 seconds ---
11+
Mean SHA256 --- 3.34592175484 seconds ---
12+
Min SHA256 --- 3.05559492111 seconds ---
13+
Max SHA256 --- 5.15194511414 seconds ---
14+
Var SHA256 --- 0.193734927024 seconds ---
15+
DP SHA256 --- 0.440153299458 seconds ---

report.py

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# coding=utf-8
12
from PasswordBase.base_reader import decrypt_base_password, read_password_base
23
from PasswordBase.base_writer import writeNewBase
34
from PasswordConvertion.convertion import encrypt_to_sha256, encrypt_to_sha1, encrypt_to_md5
@@ -8,74 +9,63 @@
89
base_file_path = './PasswordBase/'
910

1011

11-
def countTime(hashName, converstionFunc):
12+
def count_time(hash_name, converstion_func):
1213
start_time = time.time()
1314
base_list = read_password_base(base_file_path + 'base.txt')
1415
list = decrypt_base_password(base_list)
15-
convert_list(list, converstionFunc, hashName)
16+
convert_list(list, converstion_func, hash_name)
1617
timeUsed = (time.time() - start_time)
17-
# print("TIMEUSED %s --- %s seconds ---" % (hashName, timeUsed))
1818
return timeUsed
1919

20+
times = 50
2021

21-
def convert_list(list, convertionFunc, hashName):
22+
def convert_list(list, convertion_func, hash_hame):
2223
for line in list:
23-
line[1] = convertionFunc(line[1])
24-
writeNewBase(base_file_path + 'base_' + hashName + '.txt', list)
24+
line[1] = convertion_func(line[1])
25+
writeNewBase(base_file_path + 'base_' + hash_hame + '.txt', list)
2526

2627

2728
def reportMD5():
2829
md5Times = []
29-
for x in range(0, 10):
30-
md5Times.append(countTime('md5', encrypt_to_md5))
30+
for x in range(0, times):
31+
md5Times.append(count_time('md5', encrypt_to_md5))
3132

3233
report('MD5', md5Times)
33-
# print md5Times
34-
# mean = np.average(md5Times)
35-
# print("Mean %s --- %s seconds ---" % ('md5', mean))
3634
return md5Times
3735

3836

3937
def reportSHA1():
4038
sha1Times = []
41-
for x in range(0, 10):
42-
sha1Times.append(countTime('sha1', encrypt_to_sha1))
39+
for x in range(0, times):
40+
sha1Times.append(count_time('sha1', encrypt_to_sha1))
4341

4442
report('SHA1', sha1Times)
45-
# print md5Times
46-
# mean = np.average(sha1Times)
47-
# print mean
48-
# print("Mean %s --- %s seconds ---" % ('sha1', mean))
4943
return sha1Times
5044

5145

5246
def reportSHA256():
5347
sha256Times = []
54-
for x in range(0, 10):
55-
sha256Times.append(countTime('sha256', encrypt_to_sha256))
48+
for x in range(0, times):
49+
sha256Times.append(count_time('sha256', encrypt_to_sha256))
5650

5751
report('SHA256', sha256Times)
5852
return sha256Times
5953

6054

6155
def report(name, array):
62-
mean = np.average(array)
63-
min = np.amin(array)
64-
max = np.amax(array)
6556
var = np.var(array)
66-
dp = np.sqrt(var)
6757

68-
print("Mean %s --- %s seconds ---" % (name, mean))
69-
print("Min %s --- %s seconds ---" % (name, min))
70-
print("Max %s --- %s seconds ---" % (name, max))
58+
print("Mean %s --- %s seconds ---" % (name, np.average(array)))
59+
print("Min %s --- %s seconds ---" % (name, np.amin(array)))
60+
print("Max %s --- %s seconds ---" % (name, np.amax(array)))
7161
print("Var %s --- %s seconds ---" % (name, var))
72-
print("DP %s --- %s seconds ---" % (name, dp))
62+
print("DP %s --- %s seconds ---" % (name, np.sqrt(var)))
7363

7464

7565
def ploting(x1, x2, x3):
76-
plt.plot(x1, 'r--', marker='o', label='MD5')
77-
plt.plot(x2, 'b--', marker='o', label='SHA1')
78-
plt.plot(x3, 'g--', marker='o', label='SHA256')
66+
plt.plot(x1, 'r--', label='MD5')
67+
plt.plot(x2, 'b--', label='SHA1')
68+
plt.plot(x3, 'g--', label='SHA256')
7969

8070
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
8171
ncol=2, mode="expand", borderaxespad=0.)
@@ -90,5 +80,3 @@ def ploting(x1, x2, x3):
9080
x3 = reportSHA256()
9181

9282
ploting(x1, x2, x3)
93-
94-
# http://stackoverflow.com/questions/20412038/printing-python-code-to-pdf OLHAR

time_comparation.png

-1.3 KB
Loading

0 commit comments

Comments
 (0)