Search code examples
androidprotocol-buffers

How to open and read the generated .pb file of Protobuf DataStore?


I was trying out the new DataStore Library and was successfully able to use it. But I was wondering how I could look at / decode the generated file that it generated. I am very new to protobuf and not yet aware of much of it. Is there a way I could read the file I generated?

The reason why I want to read/decode back the file is to know whether,

  1. if i defined a protobuf with: bool show_prop = 1;, will the property name show_prop be readable when the file gets decoded?

  2. What parts of the generated file should be encrypted or do I have to encrypt the data at all?

  3. Is there a way to encrypt the whole generated file instead?

Thanks in advance.


Solution

  • Might be little late to answer.

    You can install protobuf command line tool (preferably from homebrew) and decode the generated file (or even encode and do a lot more).

    Can use the below command to see the decoded readable values.

    protoc --decode [message_name] [.proto_file_path] < [binary_file_path]
    

    By default, the field values are not encrypted. You can perhaps encrypt the individual values before putting it into protobuf if not interested in exploring other options like encrypting the complete file.