基于asp.net的登录页面开发
程序员文章站
2023-12-28 13:20:16
...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;
using LitJson;
using PUB;
namespace XYDWXTWeb.Apis
{
/// <summary>
/// moblogin 的摘要说明
/// </summary>
public class moblogin : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request.HttpMethod == "POST")
{
if (context.Request.Form["loginData"] != null)
{
string data = context.Request.Form["loginData"].ToString();
string[] strs = data.Split(new char[] { '=', '&' });
if (strs.Length >= 4)
{
string userName = strs[1];
string password = strs[3];
if (BLL.BLLStudentsInfo.Login(userName, password))
{
//作为密码方式加密
// 所有公共文件 统一写入PUB项目中 在不同文件中引用
string now = DateTime.Now.ToString("yyyyMMddHHmm");
string PassCheck = MD5.Encrypt(userName+"&"+now, 32);
string info = userName + "&" + password;
PermitManger.AddPermit(PassCheck, info);
//Results reslt = new Results(200, "T",PassCheck);
Results reslt = new Results(200,PassCheck);
//reslt.code = 200;
//reslt.Msg = "Success";
//reslt.data = "{}";
string data1 = JsonUnity.ToJson(reslt);
context.Response.Write(data1);
}
else
{
//Results reslt = new Results(100, "F", "");
Results reslt = new Results(210, "");
string data2 = JsonUnity.ToJson(reslt);
context.Response.Write(data2);
}
}
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
这段代码中用到了简单的md5加密(折叠),md5只能勉强算是一种加密算法,它只能加密而不能解密