例如我在添加管理员 写到数据库的密码字段是加密的 然后我在登陆的时候 我依然可以登陆 这一加密 和解密的过程我应该怎么写呢 恳请各位给指点一下 :
我写入的代码:这里怎么加密写入:
SqlCommand cmd = new SqlCommand("insert into admin values('" + this.adminname.Text.ToString().Trim() + "','" + this.adminpwd.Text.ToString().Trim() + "',1)", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('添加成功')</script>");
那么我在登陆的时候: 这里要怎么来写呢
protected void Submit1_ServerClick(object sender, EventArgs e)
{
SqlConnection con = DB.condb();
SqlCommand cmd = new SqlCommand("select count(*) from admin where adminname='" + this.adminname.Text.ToString() + "'and adminpwd='" + this.adminpwd.Text.ToString() + "'", con);
try
{
con.Open();
int ln = Convert.ToInt32(cmd.ExecuteScalar().ToString());
con.Close();
if (ln > 0)
{
Session["adminname"] = this.adminname.Text.ToString();
Response.Write("<script language='javascript'>alert('登陆成功!');window.location.href='admin.aspx';</script>");
}
else
{
Response.Write("<script language='javascript'>alert('密码或者用户名字错误,请重新登陆!');window.location.href='login.aspx';</script>");
}
}
catch(SqlException ex)
{
Response.Write(ex);
}
}
}
谢谢朋友们了 !!!向你们学习