public ActionResult Post(string signature, string timestamp, string nonce, string echostr) { if (!CheckSignature.IsValid(signature, timestamp, nonce, echostr)) { return(Content("无效的签名值: " + signature + "。")); } return(Content(string.Empty)); }
public ActionResult Get(string signature, string timestamp, string nonce, string echostr) { if (!CheckSignature.IsValid(signature, timestamp, nonce)) { App_Start.LogConfig.SaveByKey("LocalSignature", CheckSignature.GetLocal()); return(Content("签名验证失败。")); } return(Content(echostr)); }
public void GetTest() { { var signature = "bd18cc0c442ce7f5030dd4c88963b0a98a6c7057"; var echostr = "1392345180215823675"; var timestamp = "1398064395"; var nonce = "1054823587"; var token = "ShurikenWX"; CheckSignature.IsValid(signature, timestamp, nonce, token); var result = CheckSignature.GetLocal(); Assert.AreEqual(signature, result); } }