1. private void Valid()
2. {
3. string echoStr = Request.QueryString["echoStr"].ToString();
4. if (CheckSignature())
5. {
6. if (!string.IsNullOrEmpty(echoStr))
7. {
8. Response.Write(echoStr);
9. Response.End();
10. }
11. }
12. }
1. private bool CheckSignature()
2. {
3. string signature = Request.QueryString["signature"].ToString();
4. string timestamp = Request.QueryString["timestamp"].ToString();
5. string nonce = Request.QueryString["nonce"].ToString();
6. string[] ArrTmp = { Token, timestamp, nonce };
7. Array.Sort(ArrTmp); //字典排序
8. string tmpStr = string.Join("", ArrTmp);
9. tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
10. tmpStr = tmpStr.ToLower();
11. if (tmpStr == signature)
12. {
13. return true;
14. }
15. else
16. {
17. return false;
18. }
19. }
2. {
3. string echoStr = Request.QueryString["echoStr"].ToString();
4. if (CheckSignature())
5. {
6. if (!string.IsNullOrEmpty(echoStr))
7. {
8. Response.Write(echoStr);
9. Response.End();
10. }
11. }
12. }
1. private bool CheckSignature()
2. {
3. string signature = Request.QueryString["signature"].ToString();
4. string timestamp = Request.QueryString["timestamp"].ToString();
5. string nonce = Request.QueryString["nonce"].ToString();
6. string[] ArrTmp = { Token, timestamp, nonce };
7. Array.Sort(ArrTmp); //字典排序
8. string tmpStr = string.Join("", ArrTmp);
9. tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
10. tmpStr = tmpStr.ToLower();
11. if (tmpStr == signature)
12. {
13. return true;
14. }
15. else
16. {
17. return false;
18. }
19. }
大家可以分享代码 互相交流
CSDN博客:http://blog.csdn.net/weixin_net
http://blog.csdn.net/weixin_net/article/details/23964829