0
votes

I'm new to Google Protobuf. I want to solve an issue and i can't find the answer on the internet, maybe i'm asking the wrong questions..

I want to build a tool which uses a .proto schema (and the generated classes) and convert input strings from readable to base64 string and the reverse (with java) the purpose is to debug the messages. I don't know exactly which message is encoded (so which class to use..)

how can i proceed please? could you give me some pointers, links to projects or anything that may help me..

edit: for the moment, i will try to use ParseFromString function, with every class until i find the protobuf class that matches the base64 blob ..

Thank you

1
Have a look at java.util.Base64. I don't think this has anything to do with Protobuf whatsoever. - Thomas Timbul
@ThomasTimbul, first, thank you for your answer.. but when i decode the message using Base64, it do not provide to me a correct human readable string. I must somehow match it with the corresponding protobuf class to read clear values.. - Walidou
Is this something you just need to do once, to identify the type? Or something you need to do every time? If once: protoc has a decode-raw API that shows the data layout. Or you can use protogen.marcgravell.com/decode - Marc Gravell

1 Answers

0
votes

Protobuf can be used to serialize data on 1 machine and send it to the 2nd machine where it is de-serialized to the original form.

Protobuf uses its own logic to serialize things like Strings, Signed/Unsigned number values, etc

So knowing this, protobuf cannot/shouldnot be used as a converter to convert things into other things. It is used to transport data accross machine boundaries.

Maybe you just want to convert a String into BASE64 representation without protobuf? Then the hint of Thomas Timbul might be useful for you.