我在C#中使用这段简单的代码创建了一个Unity项目:
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] keyBytes = encoding.GetBytes(Manager.Instance.Configuration.ClientSecretKey);
HMACSHA1 hmacsha1 = new HMACSHA1(keyBytes);
它适用于所有平台:Unity Editor,Android,iPhone,... 但不是在Windows Phone上!以下是异常的屏幕截图。
我不明白为什么会发生这种情况,因为keyBytes显然是一个byte []对象......
答案 0 :(得分:2)
你是如何使用System.Text.ASCIIEncoding
的?
请尝试System.Text.UTF8Encoding
。
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();