def hex_dump(hex_cmd):
"""
return hexdump in html formatted data
:param hex_cmd:
:return: str
"""
hex_string = getoutput(hex_cmd)
# Format the data
html_string = ''
hex_rows = hex_string.split('\n')
for row in hex_rows:
if len(row) > 9:
off_str = row[0:8]
hex_str = row[9:58]
asc_str = row[58:78]
asc_str = asc_str.replace('"', '"')
asc_str = asc_str.replace('<', '<')
asc_str = asc_str.replace('>', '>')
html_string += '<div class="row"><span class="text-info mono">{0}</span> ' \
'<span class="text-primary mono">{1}</span> <span class="text-success mono">' \
'{2}</span></div>'.format(off_str, hex_str, asc_str)
# return the data
return html_string
评论列表
文章目录