mirror of
https://github.com/iKarith/cppo-ng.git
synced 2025-02-19 07:31:36 +00:00
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.
Description
Languages
Python
100%