This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fingerfarbe.py
74 lines (64 loc) · 1.75 KB
/
fingerfarbe.py
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
from re import findall
from bottle import route, run, template, request
header = '''
<html>
<head>
<style>
.fingerprint {
display:inline-block;
padding: 3% 0;
margin-bottom: 2%;
width: 10%;
font-family: monospace;
font-size: 175%;
text-align: center;
text-shadow: 0 0 1px #CCCCCC;
}
</style>
</head>
<body>
'''
footer = '''
<br /><br />
<small><a href="https://github.com/HorayNarea/Fingerfarbe">https://github.com/HorayNarea/Fingerfarbe</a></small>
</body>
</html>
'''
form = '''
<form>
Fingerprint:<br />
<input type="text" name="fingerprint" autofocus />
<input type="submit" value="Generate" />
</form>
'''
def colorize(fpr):
color = ''
for index, val in enumerate(fpr):
color += val
if ((index + 1) % 4 == 0) or ((index + 2) % 4 == 0):
color += 'F'
fingerfarbe = []
for chunk in findall('......', color):
fingerfarbe.append(chunk)
fingerprint = []
for chunk in findall('....', fpr):
fingerprint.append(chunk)
return fingerfarbe, fingerprint
@route('/')
def index():
farben = ''
if request.GET.get('fingerprint'):
try:
fpr = request.GET.get('fingerprint').replace(' ', '')
int(fpr, 16)
if len(fpr) == 40:
pass
else:
return template(header + form + 'Fingerprint-length must be exactly 40 characters' + footer)
except:
return template(header + form + 'Fingerprint must be a hex string!' + footer)
tup = colorize(fpr)
for i in range(10):
farben += '<div class="fingerprint" style="background-color:#' + tup[0][i] + ';">' + tup[1][i] + '</div>'
return template(header + farben + form + footer)
run(host='', port=8080, debug=True)