INNER CODE UNIT · Python
load_input_bytes
2akouwu/reverify · reverify/cli.py:51
def load_input_bytes(input_val: str, offset: int = 0, length: int = 0) -> bytes:
"""Load bytes from a hex string or from a file path."""
if os.path.exists(input_val):
with open(input_val, "rb") as f:
if offset > 0:
f.seek(offset)
if length > 0:
return f.read(length)
return f.read()
else:
# Treat as hex string
clean_hex = "".join(input_val.split()).replace("0x", "").replace("0X", "")
return bytes.fromhex(clean_hex)
def extract_strings(data: bytes, min_len: int = 4) -> List[Dict[str, Any]]:
"""Extract ASCII and UTF-16LE strings with file offsets."""
results = []