common.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:VolUtility 作者: kevthehermit 项目源码 文件源码
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('<', '&lt;')
            asc_str = asc_str.replace('>', '&gt;')
            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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号