-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhist.py
More file actions
60 lines (48 loc) · 1.63 KB
/
hist.py
File metadata and controls
60 lines (48 loc) · 1.63 KB
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
#!/usr/bin/env python3
import json
from matplotlib import pyplot as plt
def weather_hist():
with open('data/weather.json', 'r') as file:
data = json.loads(file.read())['hourly']['data']
items = ['temperature', 'humidity', 'windSpeed', 'cloudCover', 'ozone']
for item in items:
x = [value[item] for value in data]
print(*x, sep = ', ')
plt.hist(x, alpha = 0.5)
plt.ylabel('Value')
plt.title(item)
plt.savefig('images/' + item + '.png')
plt.clf()
def password_hist():
with open('data/passwords.json', 'r') as file:
data = json.loads(file.read())
x = []
for password in data:
key = password.encode('ascii').hex()[0]
for i in range(8):
if int(key) & (2 ** i):
x.append(i + 1)
bins = [num + 0.5 for num in range(4)]
plt.hist(x, bins = bins, alpha = 0.5)
plt.ylabel('Value')
plt.title('passwordBits')
plt.savefig('images/passwords.png')
plt.clf()
def key_hist(mode):
x = []
with open('data/' + mode + '_keys.txt', 'r') as file:
for line in file.readlines():
for i in range(8):
if int(line[0] + line[1], 16) & (2 ** i):
x.append(i + 1)
bins = [num + 0.5 for num in range(9)]
plt.hist(x, bins = bins, alpha = 0.5)
plt.ylabel('Value')
plt.title('keyBits')
plt.savefig('images/' + mode + '_keys.png')
plt.clf()
if __name__ == '__main__':
weather_hist()
password_hist()
key_hist('hkdf')
key_hist('pbkdf2')