aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/contentviews/hex.py
blob: 116ed600d9fe2d170bffb0c5103510fcf4c44162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from mitmproxy.utils import strutils
from . import base


class ViewHex(base.View):
    name = "Hex"
    prompt = ("hex", "e")
    content_types = []

    @staticmethod
    def _format(data):
        for offset, hexa, s in strutils.hexdump(data):
            yield [
                ("offset", offset + " "),
                ("text", hexa + "   "),
                ("text", s)
            ]

    def __call__(self, data, **metadata):
        return "Hex", self._format(data)