T. Joseph Carter f3b5fe7dcd Added hexdump function
What's wrong with b2a_hex() or hex()?  Well, hex() only converts integers.  And
while a2b_hex() ignores whitespace, b2a_hex() doesn't provide any, making for
difficult to read output for anything longer than about 8 bytes or so.

In the basic case, it seems like you want a classic hexdump.  I chose the xxd
format:

xxxxxxxx: xxxx xxxx xxxx xxxx  xxxx xxxx xxxx xxxx |cccccccccccccccc|

Rather than hardcode all of the integers and strings (as I started doing), I
decided that I might as well use variables for these things if only for
readability.  And if they're locals, you might as well be able to override
them.

The knobs you have to play with are therefore these:

- wordsize=2, how many bytes are grouped together
- sep=' ', the spacing between words
- sep2='  ', the midpoint spacing

I suppose I could've made everything else configurable too, but YAGNI.
2017-07-02 15:45:28 -07:00
2017-06-24 03:11:26 -07:00
2017-07-02 15:45:28 -07:00
Description
Rewriting cppo one piece at a time
153 KiB
Languages
Python 100%