-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeyDecode.py
More file actions
91 lines (55 loc) · 1.64 KB
/
KeyDecode.py
File metadata and controls
91 lines (55 loc) · 1.64 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
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
#This file contains all the various KEY decode functions
#We have to find the correct key order
def KeyValue(KeyList, component):
x = int(KeyList[component], 16)
return x
def OrderByKeyList(Key):
i = 0
templist = []
orderedhexlist = []
while not i == 4:
templist.append(KeyValue(Key, i))
i = i + 1
templist = sorted(templist, reverse=True)
for value in templist:
orderedhexlist.append(hex(value)[2:])
return orderedhexlist
def OrderKey(keyDict, orderedKeyLis):
OrderedKeyHash = {}
numbers = range(0, 4)
for x in numbers:
OrderedKeyHash[x] = 0
i = 0
while not i == 4:
n = 0
while not n == 4:
if orderedKeyLis[i] == keyDict[n]:
OrderedKeyHash[i] = n
n = n + 1
i = i + 1
return OrderedKeyHash
def FlipDictionary(Dict):
iList = range(0, 4)
FlippedDict = {}
i = 0
while not i > 3:
for value in iList:
if Dict[value] == i:
FlippedDict[i] = value
i = i + 1
return FlippedDict
def ConvertToList(Key):
Keylist = []
i = 0
n = 0
while not i == 4:
n = 0
while not n > 3:
if n == 3:
tempstring = Key[i][n:]
else:
tempstring = Key[i][n:(n+1)]
Keylist.append(tempstring)
n = n + 1
i = i + 1
return Keylist