2

I would like to decode protobuf.

Example of the protobuf data:0a06282c0241057a10011805220d080510bea3f493062a03010c1628f1a6f493063002382b4001481482010f383634333233303532343736343839

I can Decoding online (e.g. viahttps://protobuf-decoder.netlify.app/) works fine.

The website decode Protobuf without having the original .proto files. And all decoding is done locally via JavaScript (Contribute onGitHub).

How can I do this in python?

I trythis solution but not exist .proto file.

askedDec 12, 2023 at 6:42
henrry's user avatar
1

1 Answer1

0

Take the raw decoding from that site and you write a.proto file yourself.

For example, taking the first rows of the output:

Byte Range  Field Number    Type    Content0-8                 1       string  (,Az8-10                2       varint  As Int: 1                                    As Signed Int: -110-12               3       varint  As Int: 5                                    As Signed Int: -3

you would write:

message MyMessage {    string field1 = 1;    int32 field2 = 2;    int32 field3 = 3;}

Once you figure out what the fields actually mean, you can assign more sensible names instead offieldX. If you aren't interested in some of the fields, you can leave them out of the .proto file and the protobuf decoder will ignore them.

answeredDec 13, 2023 at 7:46
jpa's user avatar
Sign up to request clarification or add additional context in comments.

2 Comments

How can I use proto file? Which module?
@henrry Read any Python protobuf tutorial, for exampleprotobuf.dev/getting-started/pythontutorial

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.