示例#1
0
        private void btnDecryptFile_Click(object sender, EventArgs e)
        {
            string inFile = txt_FileName.Text;

            if (string.IsNullOrWhiteSpace(inFile))
            {
                MessageBox.Show("请选择要解密的文件。");
                btn_selectFille.Focus();
                return;
            }
            string outFile  = inFile.Substring(0, inFile.Length - 4);
            string password = txt_pwd.Text;


            DESFileClass.DecryptFile(inFile, outFile, password);//解密文件
            if (cb_IsDel.Checked)
            {
                //删除解密前的文件
                File.Delete(inFile);
                txt_FileName.Text = string.Empty;
            }
            MessageBox.Show("解密成功");
        }
示例#2
0
        private void btnEncryptFile_Click(object sender, EventArgs e)
        {
            string inFile   = txt_FileName.Text;
            string outFile  = inFile + ".dat";
            string password = txt_pwd.Text;

            if (string.IsNullOrWhiteSpace(inFile))
            {
                MessageBox.Show("请选择要加密的文件。");
                btn_selectFille.Focus();
                return;
            }

            DESFileClass.EncryptFile(inFile, outFile, password);  //加密文件
            if (cb_IsDel.Checked)
            {
                //删除加密前的文件
                File.Delete(inFile);
            }

            txt_FileName.Text = string.Empty;
            MessageBox.Show("加密成功");
        }