BinPAC and hexadecimal representation

Hello everyone,

I ‘m working on a protocol decoder and would like to return an hexadecimal representation of a raw stream bytes. By reading some BinPac code I found the function “bytestring_to_val” to decode a stream as ASCII and I wonder if such a function exists for hexadecimal representation like will do ascii.hexlify() as example in python.

Thanks,

Not sure exactly what you need, but the get_escaped_string() function in Bro’s src/util.cc may help or give you ideas about how to write what you need.

- Jon

Thanks Jon,

In fact I would like to have as result a string which is not a hexa convertion to ASCII put just a string that shows the data as an Hex representation
For example, if in binPac we have parsed data to a bytestring object, I would like to just put the hex value to string representation not an ASCII convertion.
For example a 4 bytes data like this 03 af 3c 4c parsed as bytestring in bin pac would be converted to a string like this "\0x03\0xaf\0x3c\0x4c"

Regards,

Emmanuel.
-----Message d'origine-----