Byte Stream to Hex String

Perl one-liner

00c03a701e7900c03a702d2908004500
00602cc000003c11ba74c0a80b05c0a8
0b03043059d9004c0000000000000000
000000000000000000000001549606c8
5f9b0000004400000000000000000000
00000000000000000000000000040002
$ cat message.txt | perl -pe 's/([0-9a-f]{2})/0x$1, /g'
0x00, 0xc0, 0x3a, 0x70, 0x1e, 0x79, 0x00, 0xc0, 0x3a, 0x70, 0x2d, 0x29, 0x08, 0x00, 0x45, 0x00, 
0x00, 0x60, 0x2c, 0xc0, 0x00, 0x00, 0x3c, 0x11, 0xba, 0x74, 0xc0, 0xa8, 0x0b, 0x05, 0xc0, 0xa8, 
0x0b, 0x03, 0x04, 0x30, 0x59, 0xd9, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x96, 0x06, 0xc8, 
0x5f, 0x9b, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 

jEdit BeanShell

26 08 00 11 00 00 00 00 00 00 00 1c 72 65 73 74
72 69 63 74 20 31 39 32 2e 31 36 38 2e 37 2e 38
20 76 65 72 73 69 6f 6e 00 00 00 0a 86 be ad 02
89 51 bb 99 9d 7f 15 71 c6 a2 cf d4
Search: [0-9a-z][0-9a-z]
Replace: "0x"+_0+","
0x26, 0x08, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x72, 0x65, 0x73, 0x74,
0x72, 0x69, 0x63, 0x74, 0x20, 0x31, 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x37, 0x2e, 0x38,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x0a, 0x86, 0xbe, 0xad, 0x02,
0x89, 0x51, 0xbb, 0x99, 0x9d, 0x7f, 0x15, 0x71, 0xc6, 0xa2, 0xcf, 0xd4,

Leave a Reply

Your email address will not be published. Required fields are marked *