def intdecoder(body, width=8, signed=False):
assert type(body) == BitArray
assert width % 8 == 0
assert width in [8, 16] # for now, due to fmt.
fmt = "%03i"
if width == 16:
fmt = "%05i"
s = []
for idx in range(0, body.len, width):
value = body[idx:idx+width]
s += [fmt % (value.intle if signed else value.uintle)]
return [("ints", " ".join(s)), ('strbody', body.hex)]
评论列表
文章目录