using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyMobile;
using System.Security.Cryptography;
public partial class Register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string username = txtusername.Text;
string password = MyMobile.BLL.T_users.GetMD5(txtpassword.Text);
string email = txtmail.Text;
MyMobile.MODEL.T_users user = new MyMobile.MODEL.T_users();
user.userid = Guid.NewGuid();
user.username = username;
user.password = password;
user.email = email;
MyMobile.BLL.T_users buser = new MyMobile.BLL.T_users();
if (buser.Add(user) == true)
{
Response.Write("插入成功");
}
else
{
Response.Write("插入失败");
}
}
//计算MD5值方法
public static string GetMD5(string sDataIn)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bytValue, bytHash;
bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
bytHash = md5.ComputeHash(bytValue);
md5.Clear();
string sTemp = "";
for (int i = 0; i < bytHash.Length; i++)
{
sTemp += bytHash[i].ToString("X").PadLeft(2, '0');
}
return sTemp.ToLower();
}
}