微信账号

        string token = "abelieve321";  //你的token
        protected void Page_Load(object sender, EventArgs e)
        { 
            string signature = Request["signature"];
            string timestamp = Request["timestamp"];
            string nonce = Request["nonce"];
            string echostr = Request["echostr"]; 
            var arr = new[] { token, timestamp, nonce }.OrderBy(z => z).ToArray();
            var arrString = string.Join("", arr);
            var sha1 = System.Security.Cryptography.SHA1.Create();
            var sha1Arr = sha1.ComputeHash(Encoding.UTF8.GetBytes(arrString));
            StringBuilder enText = new StringBuilder();
            foreach (var b in sha1Arr)
            {
                enText.AppendFormat("{0:x2}", b);
            }
            if (enText.ToString() == signature)
            { 
                if (!string.IsNullOrEmpty(echostr))
                { 
                    Response.Write(echostr);
                    Response.End();
                } 

            }
 
        } 
原文地址:https://www.cnblogs.com/songxxu/p/3567191.html