生成带校验权限的访问页面
2017-02-26 20:33:46 访问(1439) 赞(0) 踩(0)
/// <summary>
/// 页面加密密钥
/// </summary>
protected readonly static string pageSignKey
=
System.Configuration.ConfigurationManager.AppSettings
["SlowX.WebSite.BLL.WebSiteBasicBLL.pageSignKey"];
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public string WebSiteMD5(string text)
{
return GetGB2312MD5(text + pageSignKey);
}
/// <summary>
///
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public bool WebSiteMD5Check(string text,string sign)
{
return GetGB2312MD5(text + pageSignKey) == sign;
}
/// <summary>
/// 构建参数
/// </summary>
/// <param name="curId"></param>
/// <returns></returns>
public string BuildDownLoadParams(long curId)
{
StringBuilder theResult = new StringBuilder();
string dt = DateTime.Now.ToString("yyyyMMddHHmmss");
string guid = System.Guid.NewGuid().ToString("N");
theResult.Append("?id=" + curId.ToString());
theResult.Append("&dt=" + HttpContext.Current.Server.UrlEncode(dt));
theResult.Append("&guid=" + HttpContext.Current.Server.UrlEncode(guid));
string str = curId.ToString() + dt + guid + pageSignKey;
str = GetGB2312MD5(str);
theResult.Append("&sign=" + str);
return theResult.ToString();
}
/// <summary>
/// 构建参数
/// </summary>
/// <param name="curId"></param>
/// <param name="dt"></param>
/// <param name="guid"></param>
/// <returns></returns>
public string BuildDownLoadParams(long curId, string dt, string guid)
{
StringBuilder theResult = new StringBuilder();
theResult.Append("?id=" + curId.ToString());
theResult.Append("&dt=" + HttpContext.Current.Server.UrlEncode(dt));
theResult.Append("&guid=" + HttpContext.Current.Server.UrlEncode(guid));
string str = curId.ToString() + dt + guid + pageSignKey;
str = GetGB2312MD5(str);
theResult.Append("&sign=" + str);
return theResult.ToString();
}
/// <summary>
/// 校验参数
/// </summary>
/// <returns></returns>
public bool CheckDownLoadParams()
{
string curId = HttpContext.Current.Request.QueryString["id"];
string dt = HttpContext.Current.Request.QueryString["dt"];
string guid = HttpContext.Current.Request.QueryString["guid"];
string sign = HttpContext.Current.Request.QueryString["sign"];
if (curId == null || dt == null || guid == null || sign == null)
return false;
curId = HttpContext.Current.Server.UrlDecode(curId);
dt = HttpContext.Current.Server.UrlDecode(dt);
guid = HttpContext.Current.Server.UrlDecode(guid);
sign = HttpContext.Current.Server.UrlDecode(sign);
string str = curId + dt + guid + pageSignKey;
str = GetGB2312MD5(str);
return (sign == str);
}
标签:
生成带校验权限的访问页面 


上一条:
下一条:
相关评论
发表评论