格 千格 KiloCell

Protobuf decoder

Even without Schema, the Protocol Buffers binary data can be analysed online and restored

Binary data (Hex or Base64)
Structure View After Decoding
Waiting for input data to decode...

Protobuf decoder: In-depth understanding of the binary structure of Protocol Buffers

Protocol Buffers (Protobuf) is a lightweight and efficient structured data storage format developed by Google. With JSON or XML Unlike, Protobuf is a binary format designed to pursue extreme backlog indentation and decomposition speed. No, not yet. .proto Direct reading of these binary streams is almost impossible in the case of the definition document (Schema). This tool helps developers recover in a black box environment by inspiring algorithms Protobuf's message hierarchy.

Why can Protobuf decode even without Schema?

Protobuf messages consist of a series of key pairs. Each key contains one Field ID (Fild Number) And one. Wire Type 。 Wire Type Tell how the coder determines the boundary of the value (e.g., fixed length, long integer or bytes with limited length). I don't think so. Schema, we don't know the exact name of the field (e.g. user_id But we can identify it. Field 1: 150 。 This feature gives Protobuf a strong tolerance for errors and forward/backward compatibility.

2. How can this tool be used for debugging?

Input format support: You can paste a hexadecimal string (e.g.) 08 96 01 ) or Base64 encoded string. This tool automatically filters spaces, line breaks, etc.

Structured presentation: The decoding device will present complex embedded messages as a hierarchical view similar to JSON. It's self-identified. Varint (Long integer number) Length-delimited Core data types such as (strings or submessages). If a field looks like a submessage, this tool will try to decod it.

3. Identification of common data types

  • Varint (0): For int32, int64, bool etc., using Base128 Long Encoding.
  • Fixed64 (1): For sexed 64, bytes fixed length data, etc.
  • Length-delimited (2): For the string, bytes, embeded messages and packed reped fields.
  • Fixed32 (5): For fixed bytes of data for fixed 32 and floads, etc.

Common Question Answers (FAQ)

Q: Why do the numbers look strange?
A: Long integer may represent the original number or negative number that passes through the ZigZag code. Besides, it's not available Schema, we can't determine what a 4 byte block is. int32 Or is it? float 。

Q: Why isn't some embedded message automatically launched?
A: When binary data looks like a legitimate Protobuf When submessages are like normal strings, the decoding device may by default display them as Hex/String。 You can judge manually according to business logic.

Operation successfully