先看代码:
private bool CheckSignature(string token, string signature, string timestamp, string nonce)
{
string[] ArrTmp = { token, timestamp, nonce };
Array.Sort(ArrTmp);
string tmpStr = string.Join("", ArrTmp);
byte[] tmpByte = Encoding.UTF8.GetBytes(tmpStr);
tmpByte = SHA1.Create().ComputeHash(tmpByte);
tmpStr = BitConverter.ToString(tmpByte);
tmpStr = tmpStr.Replace("-", tmpStr).ToLower();
//tmpStr= BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(tmpStr))).Replace("-", "").ToLower();
if (tmpStr == signature)
{
return true;
}
else
{
return false;
}
}
这里有两点需要注意地方: