1. 程式人生 > >基於asp.net的登入頁面開發

基於asp.net的登入頁面開發

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只能勉強算是一種加密演算法,它只能加密而不能解密