Skip to content
23 changes: 23 additions & 0 deletions packet_helper_core/utils/utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)
)