⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Security.Cryptography;
using System.Text;
using System.Data.SqlClient;
using System.IO;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }
    //检测用户名是否存在
    public void  CheckUser()
    {

             SqlConnection sqlconn = new SqlConnection("server=(local);uid=sa;pwd=;database=db_08");
            string sqlstr = "select * from tb_02 where Name='" + this.txtLoginName.Text + "'";
            sqlconn.Open();
            SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn);
            SqlDataReader dr = sqlcom.ExecuteReader();
                if (dr.Read())
                {
                    if (dr[2].ToString() == "男")
                    {
                        ddlSex.SelectedIndex = 0;
                    }
                    if (dr[2].ToString() == "女")
                    {
                        ddlSex.SelectedIndex = 1;
                    }
                    txtPwd.Text = Decrypting(dr[3].ToString());//调解密方法解密
                    txtQuePwd.Text = dr[4].ToString();
                    txtAnsPwd.Text = Decrypting(dr[5].ToString());//调解密方法解密
                    txtEmail.Text = Decrypting(dr[6].ToString());//调解密方法解密

                }
                else
                {

                    Response.Write("<script>alert('没有找到任何记录!');</script>");
                }
            dr.Close();
            sqlconn.Close();
          

    }
  
   //解密字符串
    public string Decrypting(string Source)
    {
        try
        {

            //将解密字符串转换成字节数组
            byte[] bytIn = System.Convert.FromBase64String(Source);
            //建立加密对象的密钥和偏移量对TripleDES,采取24字节或192位的密钥和初始向量
            byte[] key ={ 42, 16, 93, 156, 78, 4, 218, 32, 15, 167, 44, 80, 26, 20, 155, 112, 2, 94, 11, 204, 119, 35, 184, 197 };
            byte[] IV ={ 55, 103, 246, 79, 36, 99, 167, 3 };
            //实例  TripleDESCryptoServiceProvider类将字符串写入流中
            TripleDESCryptoServiceProvider TripleDES = new TripleDESCryptoServiceProvider();
            TripleDES.IV = IV;
            TripleDES.Key = key;
            //解密流
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytIn, 0, bytIn.Length);
            ICryptoTransform encrypto = TripleDES.CreateDecryptor();
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Read);
            StreamReader strd = new StreamReader(cs, Encoding.Default);
            return strd.ReadToEnd();


        }
        catch (Exception ex)
        {
            throw new Exception("在文件解密的时候出现错误!错误提示: \n" + ex.Message);
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        CheckUser();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("<script>window.close();</script>");
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -