From 3c552903838d1f8b31c07448c5d8a8f224c2482d Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Sun, 14 Jan 2024 15:33:01 +0100 Subject: [PATCH] Fix hexdump replacement character I guess this really should be a parameter of the function, but maybe later. --- sopass.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopass.py b/sopass.py index 222b7ea..aace876 100755 --- a/sopass.py +++ b/sopass.py @@ -28,8 +28,8 @@ def hexdump(data: bytes) -> list[str]: # We will be prefixing the lines with sig offset_len = math.ceil(math.log(len(data), 16)) while data: left_chunk, right_chunk, data = data[:8], data[8:16], data[16:] - left_ascii = ''.join(chr(x) if x in range(32,127) else ',' for x in left_chunk) - right_ascii = ''.join(chr(x) if x in range(32,127) else ',' for x in right_chunk) + left_ascii = ''.join(chr(x) if x in range(32,127) else '.' for x in left_chunk) + right_ascii = ''.join(chr(x) if x in range(32,127) else '.' for x in right_chunk) offset_str = f'{offset:0{offset_len}x}' line = f"{offset_str} {left_chunk.hex(' ').ljust(23)} {right_chunk.hex(' ').ljust(23)} |{left_ascii.ljust(8)}{right_ascii.ljust(8)}|" offset += 16