Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. FMT = '{} {} |{}|'
  2.  
  3.  
  4. def hexdump_gen(byte_string, _len=16, n=0, sep='-'):
  5. while byte_string[n:]:
  6. col0, col1, col2 = format(n, '08x'), [], ''
  7. for i in bytearray(byte_string[n:n + _len]):
  8. col1 += [format(i, '02x')]
  9. col2 += chr(i) if 31 < i < 127 else '.'
  10. col1 += [' '] * (_len - len(col1))
  11. col1.insert(_len // 2, sep)
  12. yield FMT.format(col0, ' '.join(col1), col2)
  13. n += _len
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement