I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets.
Every time I
xxd is the 'standard' hex dump util and looks like it should solve your problems