Does Spicy have a hex variable type?

I want to capture some data and keep it in hex. When using the bytes variable, I get a mix of some hex and some ascii characters when printing it out. How can I keep it all in hex when it gets printed into the zeek log?

I see something like this in my log, and I want all the characters to be \x - “data”:"\x82D1E%27C\x82\x82\x82\x82\x82\x82C\x822t\x82ui\x82R$/$L\R3T

Spicy has a type bytes for raw bytes, and string for valid UTF-8 strings. The conversion between these types is explicit with bytes::decode. When e.g., printing bytes in Spicy code non-ASCII characters are replaced with their hex value, but the underlying type is still a bytes. There is no builtin function to force printing of even ASCII bytes in a hex representation.

Zeek on the other hand has just a single type string. Both a Spicy bytes and a Spicy string are mapped into a Zeek string when such a Spicy value is exported to Zeek. Zeek has a number of functions for extracting hex values, but also none of them seem to exactly match your requirement.

In either of these cases you would need to write custom code to get that particular output format.