Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FMT = '{} {} |{}|'
- def hexdump_gen(byte_string, _len=16, n=0, sep='-'):
- while byte_string[n:]:
- col0, col1, col2 = format(n, '08x'), [], ''
- for i in bytearray(byte_string[n:n + _len]):
- col1 += [format(i, '02x')]
- col2 += chr(i) if 31 < i < 127 else '.'
- col1 += [' '] * (_len - len(col1))
- col1.insert(_len // 2, sep)
- yield FMT.format(col0, ' '.join(col1), col2)
- n += _len
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement