devicer.py 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devicer/confidence.py +36 -3
- {devicer_py-0.1.4.dist-info → devicer_py-0.1.6.dist-info}/METADATA +1 -1
- devicer_py-0.1.6.dist-info/RECORD +8 -0
- devicer_py-0.1.4.dist-info/RECORD +0 -8
- {devicer_py-0.1.4.dist-info → devicer_py-0.1.6.dist-info}/WHEEL +0 -0
- {devicer_py-0.1.4.dist-info → devicer_py-0.1.6.dist-info}/licenses/license.txt +0 -0
- {devicer_py-0.1.4.dist-info → devicer_py-0.1.6.dist-info}/top_level.txt +0 -0
devicer/confidence.py
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
from .hashing import get_tlsh_hash, get_hash_difference
|
2
2
|
import math
|
3
3
|
|
4
|
+
def compare_lists(data1: list, data2: list) -> tuple[int, int]:
|
5
|
+
"""
|
6
|
+
Compare two lists and return the count of matching elements and total elements.
|
7
|
+
|
8
|
+
Args:
|
9
|
+
data1 (list): First list containing data.
|
10
|
+
data2 (list): Second list containing data.
|
11
|
+
|
12
|
+
Returns:
|
13
|
+
tuple: A tuple containing the count of matching elements and total elements compared.
|
14
|
+
"""
|
15
|
+
fields = 0
|
16
|
+
matches = 0
|
17
|
+
max_length = max(len(data1), len(data2))
|
18
|
+
for i in range(max_length):
|
19
|
+
if data1[i] and data2[i]:
|
20
|
+
fields += 1
|
21
|
+
if isinstance(data1[i], dict) and isinstance(data2[i], dict):
|
22
|
+
sub_matches, sub_fields = compare_dictionaries(data1[i], data2[i])
|
23
|
+
matches += sub_matches
|
24
|
+
fields += sub_fields - 1
|
25
|
+
elif isinstance(data1[i], list) and isinstance(data2[i], list):
|
26
|
+
sub_matches, sub_fields = compare_lists(data1[i], data2[i])
|
27
|
+
matches += sub_matches
|
28
|
+
fields += sub_fields - 1
|
29
|
+
if data1[i] == data2[i]:
|
30
|
+
matches += 1
|
31
|
+
return matches, fields
|
32
|
+
|
4
33
|
def compare_dictionaries(data1: dict, data2: dict) -> tuple[int, int]:
|
5
34
|
"""
|
6
35
|
Compare two dictionaries and return the count of matching fields and total fields.
|
@@ -21,7 +50,11 @@ def compare_dictionaries(data1: dict, data2: dict) -> tuple[int, int]:
|
|
21
50
|
sub_matches, sub_fields = compare_dictionaries(data1[key], data2[key])
|
22
51
|
matches += sub_matches
|
23
52
|
fields += sub_fields - 1 # Subtract 1 to avoid double counting the key
|
24
|
-
elif data1[key]
|
53
|
+
elif isinstance(data1[key], list) and isinstance(data2[key], list):
|
54
|
+
sub_matches, sub_fields = compare_lists(data1[key], data2[key])
|
55
|
+
matches += sub_matches
|
56
|
+
fields += sub_fields - 1
|
57
|
+
if data1[key] == data2[key]:
|
25
58
|
matches += 1
|
26
59
|
return matches, fields
|
27
60
|
|
@@ -46,8 +79,8 @@ def calculate_confidence(data1: dict, data2: dict) -> float:
|
|
46
79
|
difference_score = get_hash_difference(hash1, hash2)
|
47
80
|
|
48
81
|
inverse_match_score = 1 - (matches / fields)
|
49
|
-
x =
|
82
|
+
x = 1.3 * difference_score * inverse_match_score
|
50
83
|
if (inverse_match_score == 0 or difference_score == 0):
|
51
84
|
return 100
|
52
|
-
confidence_score = 100 / (1 + math.e ** (-4.5 + (0.
|
85
|
+
confidence_score = 100 / (1 + math.e ** (-4.5 + (0.3 * x)))
|
53
86
|
return confidence_score
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: devicer.py
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
4
4
|
Summary: Open-Source Python Middleware for Digital Fingerprinting
|
5
5
|
Author: One anonymous contributor
|
6
6
|
Author-email: Samuel Roux <sam.roux.com@gmail.com>, Stephen Perso <stephenrperso@gmail.com>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
devicer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
devicer/confidence.py,sha256=TFL_y7t3lBkSWKXMcfbggCeBEkl4vd6aIs5elsl0kR4,3380
|
3
|
+
devicer/hashing.py,sha256=drqu_9YA7UbcaxgSiD3lWP5qkce6-0c-HHWmqyJi4Tg,645
|
4
|
+
devicer_py-0.1.6.dist-info/licenses/license.txt,sha256=z84l2WzrGJ9egXM0Gcgl2_G1GK_L6OtqP3SBi5aKOxg,1171
|
5
|
+
devicer_py-0.1.6.dist-info/METADATA,sha256=n4xIxSxpGGAF9XMZ7SHczbtMyvGywAyFMn0wazwmD0Y,1752
|
6
|
+
devicer_py-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
devicer_py-0.1.6.dist-info/top_level.txt,sha256=U7avJlzadMpnTLycX86eYZWIZxZAffgTkOj0MmZ6VvY,8
|
8
|
+
devicer_py-0.1.6.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
devicer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
devicer/confidence.py,sha256=nHE66vJaVKuQxFNT4DSjGB8Y7O4VRhlenf5ZNbfOfno,1991
|
3
|
-
devicer/hashing.py,sha256=drqu_9YA7UbcaxgSiD3lWP5qkce6-0c-HHWmqyJi4Tg,645
|
4
|
-
devicer_py-0.1.4.dist-info/licenses/license.txt,sha256=z84l2WzrGJ9egXM0Gcgl2_G1GK_L6OtqP3SBi5aKOxg,1171
|
5
|
-
devicer_py-0.1.4.dist-info/METADATA,sha256=genA0ySj505QQEyenL4CtjR6xyIcoRR04NBFTFa5nHY,1752
|
6
|
-
devicer_py-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
devicer_py-0.1.4.dist-info/top_level.txt,sha256=U7avJlzadMpnTLycX86eYZWIZxZAffgTkOj0MmZ6VvY,8
|
8
|
-
devicer_py-0.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|