Tag Archives: shell

How to produce hex array from binary data

Suppose you have a binary file you want to include as byte array into C/C++/Java program. Here how you can generate it (just add opening and closing braces and clean some garbage at the end)

hexdump -v -e " 16/1 \"0x%02X, \" \"\n\""

Something like the following will be produced:


0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0xF9, 0xE7, 0x9F, 0x7F,
0xFE, 0xF9, 0xE7, 0x9F, 0x7F, 0xFE, 0x0F, 0xFD, 0x3F, 0x4F, 0xAC, 0x0A, 0xA2, 0x00, 0xB0, 0x94,
0x01, 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x , 0x ,