我正在使用protobuf传递一个哈希字节数组。但是在尝试反序列化时,会出现以下错误:
我认为这只是一个编码/解码的简单问题,但我不知道如何做。
这是在C#中对数据进行编码的代码:
代码很简单:'utf-8'编解码器无法解码位置1处的0xd6字节:'utf-8'编解码器无法解码位置1处的0xd6字节,因为它是一个无效的连续字节。
字段:master.hash1
a = message.ParseFromString(data)
我认为这只是一个编码/解码的简单问题,但我不知道如何做。
这是在C#中对数据进行编码的代码:
public byte[] HmacSign(string key, string message)
{
var encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(key);
HMACSHA1 hmacsha1 = new HMACSHA1(keyByte);
byte[] messageBytes = encoding.GetBytes(message);
byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);
return hashmessage;
}