Decoding protobuf without schema

前端 未结 1 677
一向
一向 2021-01-18 01:35

Is it possible to decode protobuf serialized files without schema with tools or anything that would decode the binary data to readable format?

相关标签:
1条回答
  • 2021-01-18 01:59

    You can often deduce the schema. In fact, IIRC the "protoc" tool has a set of parameters (--decode_raw, iirc) where it will do precisely that - making informed guesses. However, it is a guess - the format is ambiguous in that multiple different types of data can be stored in the same mechanisms - for example, a length-prefixed chunk could be:

    • a sub-object (of any user type)
    • a packed array (of various primitive types)
    • a utf-8 string
    • a raw byte[]
    • and probably something else I'm forgetting

    Likewise, a 4-byte fixed-width chunk could be a fixed-width integer, or a float; the integer could be signed or unsigned.

    0 讨论(0)
提交回复
热议问题