using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
namespace WebApplication1
{
/// <summary>
/// wx 的摘要说明
/// </summary>
public class wx : IHttpHandler
{
string Token = "www0430com";
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
if (string.IsNullOrEmpty(context.Request.QueryString["echoStr"])) { context.Response.End(); }
string echoStr = context.Request.QueryString["echoStr"].ToString();
if (CheckSignature(context))
{
if (!string.IsNullOrEmpty(echoStr))
{
context.Response.Write(echoStr);
context.Response.End();
}
}
}
private bool CheckSignature(HttpContext context)
{
string signature = context.Request.QueryString["signature"].ToString();
string timestamp = context.Request.QueryString["timestamp"].ToString();
string nonce = context.Request.QueryString["nonce"].ToString();
string[] ArrTmp = { Token, timestamp, nonce };
Array.Sort(ArrTmp); //字典排序
string tmpStr = string.Join("", ArrTmp);
tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
tmpStr = tmpStr.ToLower();
if (tmpStr == signature)
{
return true;
}
else
{
return false;
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
接口配置信息【ashx】
最新推荐文章于 2022-11-17 17:16:22 发布