Restoring .proto file from descriptor string. Possible?

前端 未结 2 470
面向向阳花
面向向阳花 2021-01-03 10:06

Is it possible to decompile a string containing Protocol Buffers descriptor back to .proto file?

Say I have a long string like

\\n\\file.proto\\u001a\

2条回答
  •  一生所求
    2021-01-03 10:20

    Yes it should be possible to get some thing close get original definition. I do not know of any existing code to do it (hopefully some one else will).

    Hava a look at how protocol buffers itself handles the String.

    Basically

    1. convert the string to bytes (using charset="ISO-8859-1" in java), it will then be a Protocol-Buffer message(format=FileDescriptorProto in java). The FileDescriptorProto is built as part of the Protocol-Buffers install.

    2. Extract the data in the Protocol-Buffer message

    Here is a File-Descriptor protocol displayed in the Protocol-Buffer editor

    enter image description here

提交回复
热议问题