ハッシュされたバイト配列をprotobufを使って渡しています。しかし、それをデシリアライズしようとしている間、私は次のエラーを取得しています:pythonのprotobufバイトフィールドを逆シリアル化できません
'utf-8' codec can't decode byte 0xd6 in position 1: 'utf-8' codec can't decode byte 0xd6 in position 1: invalid continuation byte in field: 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;
}
ですあなたのデータはutf-8でエンコードされていますか? – Isma