本文介绍了ASP.Net中的加密和解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我计划在我的程序中加密和解密数据库,但我不知道应该从哪里开始。我可以在SubmitPage和登录页面上的解密中加密我的加密代码吗?或者我需要把它放在其他地方吗?
这是提交页面:
I planned to encrypt and decrypt the database in my program but I don''t know where I should start. Can I have my encryption code on the SubmitPage and the Decryption on the login page? Or do I need to put it some where else?
This is the Submit page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
public partial class SubmitPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PassConnectionString"].ConnectionString);
con.Open();
string cmdStr = "Select count(*) from TableSecurity where EmailAddress='" + TextBoxEA.Text + "'";
string cmdStr2 = "Select count(*) from TableCEO where EmailAddress ='" + TextBoxEA.Text + "'";
string cmdStr3 = "Select count(*) from TableIALO where EmailAddress ='" + TextBoxEA.Text + "'";
SqlCommand userExist = new SqlCommand(cmdStr, con);
SqlCommand cmd = new SqlCommand("select * from TableSecurity", con);
SqlCommand cmd2 = new SqlCommand("select * from TableCEO", con);
SqlCommand cmd3 = new SqlCommand("select * from TableIALO", con);
int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString());
if (temp == 1)
Response.Write("User Name Already Exist!!!<br /> Please Choose Another User Name.");
}
}
protected void Submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PassConnectionString"].ConnectionString);
con.Open();
string chkUser = "select count(*) from TableCEO where EmailAddress'" + TextBoxEA.Text + "";
chkUser = "select count(*) from TableIALO where EmailAddress'" + TextBoxPW.Text + "";
SqlCommand chkUsercmd = new SqlCommand(chkUser, con);
string insCmd = "Insert into TableSecurity (EmailAddress, Password, AccessLevel) values (@EmailAddress, @Password, @AccessLevel)";
SqlCommand insertUser = new SqlCommand(insCmd, con);
insertUser.Parameters.AddWithValue("@EmailAddress", TextBoxEA.Text);
insertUser.Parameters.AddWithValue("@Password", TextBoxPW.Text);
try
{
insertUser.ExecuteNonQuery();
con.Close();
Response.Redirect("Login.aspx");
}
catch (Exception er)
{
Response.Write("Something Really Bad Has Happened....Please Try Again.");
}
finally
{
}
}
}
推荐答案
这篇关于ASP.Net中的加密和解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!