diff --git a/packet_helper_core/utils/utils.py b/packet_helper_core/utils/utils.py index 30fc17b..5696d53 100644 --- a/packet_helper_core/utils/utils.py +++ b/packet_helper_core/utils/utils.py @@ -1,5 +1,7 @@ import pyshark from scapy_helper import get_hex +from scapy_helper import diff as scapy_diff +from dataclasses import dataclass def hex_str_operation(h_string, with_new_line: bool = False): @@ -61,3 +63,24 @@ def better_scapy_summary(scapy_summary) -> list: } list_.append(temp_frame) return list_ + + +@dataclass +class Compare: + first_hex: str + second_hex: str + + @staticmethod + def sep_bytes(hex_str: str) -> str: + return " ".join( + [ + "".join([hex_str[e - 1], hex_str[e]]) + for e in range(len(hex_str)) + if e % 2 + ] + ) + + def hex_diff(self) -> list: + return scapy_diff( + self.sep_bytes(self.first_hex), self.sep_bytes(self.second_hex) + )