Exemplo n.º 1
0
        //新增或者编辑保存
        private void button1_Click(object sender, EventArgs e)
        {
            var model = new Record();

            string[] columns = { "标题", "网址", "账户", "密码", "二级密码", "备注", "添加时间" };

            var    des             = new DEScode(Session.password);
            string title           = des.EncryptDES(textBox1.Text);
            string website         = des.EncryptDES(textBox2.Text);
            string account         = des.EncryptDES(textBox3.Text);
            string password        = des.EncryptDES(textBox4.Text);
            string second_password = des.EncryptDES(textBox5.Text);
            string remark          = des.EncryptDES(richTextBox1.Text);

            if (textBox1.Text.Trim().Length < 1 || textBox3.Text.Trim().Length < 1 || textBox4.Text.Trim().Length < 1)
            {
                MessageBox.Show("缺少必填参数", "错误提示");
            }
            else
            {
                string[] values = { title, website, account, password, second_password, remark, DateTime.Now.ToString() };
                if (this.id > 0)
                {
                    model.update(this.id, columns, values);
                }
                else
                {
                    model.add(columns, values);
                }

                parent.List_Load(sender, e);
                this.Close();
            }
        }
Exemplo n.º 2
0
        //重新加密
        public void rebuild(string old_password, string new_password)
        {
            DataRowCollection drc = this.select();
            var old_des           = new DEScode(old_password);
            var new_des           = new DEScode(new_password);

            foreach (DataRow row in drc)
            {
                int    id              = int.Parse(row["ID"].ToString());
                string title           = new_des.EncryptDES(old_des.DecryptDES(row["标题"].ToString()));
                string website         = new_des.EncryptDES(old_des.DecryptDES(row["网址"].ToString()));
                string account         = new_des.EncryptDES(old_des.DecryptDES(row["账户"].ToString()));
                string password        = new_des.EncryptDES(old_des.DecryptDES(row["密码"].ToString()));
                string second_password = new_des.EncryptDES(old_des.DecryptDES(row["二级密码"].ToString()));
                string remark          = new_des.EncryptDES(old_des.DecryptDES(row["备注"].ToString()));

                string[] columns = { "标题", "网址", "账户", "密码", "二级密码", "备注" };
                string[] values  = { title, website, account, password, second_password, remark };

                this.update(id, columns, values);
            }
        }