Friday, 26 February 2021

google.protobuf.message.DecodeError: Wrong wire type in tag Error in Protocol Buffer

I trying decrypt my data using google protocol buffer in python

sample.proto file:-

syntax = "proto3";

message SimpleMessage {
string deviceID = 1;
string timeStamp = 2;
string data = 3;
 }

After that, I have generated python files using the proto command:- protoc --proto_path=./ --python_out=./ simple.proto

My Python code below:-

import json
import simple_pb2
import base64


encryptedData = 'eyJ2ZXIiOjEuMCwic2VxIjoxODEsInRtcyI6IjIwMjEtMDEtMjJUMTQ6MDY6MzJaIiwiZGlkIjoiUlFI'

t2 = bytes(encryptedData, encoding='utf8')
print(encryptedData)
data = base64.b64decode(encryptedData)

test = simple_pb2.SimpleMessage()
v1 =  test.ParseFromString(data)

While executing above code getting error:- google.protobuf.message.DecodeError: Wrong wire type in tag Error

What i am doing wrong. can anyone help?



from google.protobuf.message.DecodeError: Wrong wire type in tag Error in Protocol Buffer

No comments:

Post a Comment