Пример #1
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (txtName.Text == "")
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin cho trường Họ Tên!", "Thông báo");
     }
     if (txtEmail.Text == "")
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin cho trường Email!", "Thông báo");
     }
     else if (txtName.Text != "" || txtEmail.Text != "")
     {
         File.WriteAllText("configName.cfg", txtName.Text);
         File.WriteAllText("configEmail.cfg", txtEmail.Text);
         AESEncryptDecrypt.FileDecrypt("configName.cfg.aes", "file1.tmp", "cVEEdRMrnJ");
         AESEncryptDecrypt.FileDecrypt("configEmail.cfg.aes", "file2.tmp", "Lm6NzzftiB");
         string name  = File.ReadAllText("file1.tmp");
         string email = File.ReadAllText("file2.tmp");
         if (txtName.Text != name || txtEmail.Text != email)
         {
             MessageBox.Show("Thông tin không đúng, vui lòng kiểm tra lại thông tin và thử lại!", "Thông báo");
         }
         else
         {
             MessageBox.Show("Đang xác minh và mở khoá, vui lòng đợi....");
             AESEncryptDecrypt.FileDecrypt("encrypted_files.dat.aes", "tmp1.tmp", "pass123456");
             string temp1 = File.ReadAllText("tmp1.tmp");
             MessageBox.Show("Password: "******"tmp1.tmp");
         File.Delete("file1.tmp");
         File.Delete("file2.tmp");
     }
 }
Пример #2
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            AESEncryptDecrypt.FileDecrypt("encrypted_files.dat.aes", "temp1.tmp", "pass123456");
            string   pass = File.ReadAllText("temp1.tmp");
            GCHandle gch  = GCHandle.Alloc(pass, GCHandleType.Pinned);

            if (txtPasswordEnter.Text != pass || txtPasswordEnter.Text == "")
            {
                SoLanThuLai++;
                MessageBox.Show("Sai mật khẩu giải mã! Vui lòng thử lại! \nLưu ý: Mật khẩu ở ô bên dưới (Dưới dòng chữ Mật khẩu để mã hoá / giải mã file) không phải là mật khẩu chính xác! Bạn phải nhớ mật khẩu đã từng hiển thị ở ô đó vào lúc bạn mã hoá file để nhập mật khẩu!");
                if (SoLanThuLai >= 5)
                {
                    AESEncryptDecrypt.FileDecrypt(txtOutputFile.Text, txtInputFile.Text, pass);
                    SendMail();
                    MessageBox.Show("Bạn đã nhập sai mật khẩu quá 10 lần. Vì lí do bảo mật, chúng tôi sẽ tự động xoá tập tin này để đảm bảo an toàn tập tin cho chủ sỡ hữu của tập tin. Một thông báo email kèm theo tập tin đã được giải mã đã được gửi đến chủ sở hữu và tập tin đã bị xoá khỏi máy tính này!", "Thông báo");
                    Thread.Sleep(TimeSpan.FromSeconds(10));
                    File.Delete("fsIn.txt");
                    File.Delete("fsOut.txt");
                    File.Delete("temp1.tmp");
                    File.Delete("temp2.tmp");
                    File.Delete("encrypted_files.dat.aes");
                    File.Delete(txtInputFile.Text);
                    File.Delete(txtOutputFile.Text);
                }
            }
            else
            {
                AESEncryptDecrypt.FileDecrypt(txtOutputFile.Text, txtInputFile.Text, txtPasswordEnter.Text);
                //AESEncryptDecrypt.FileDecrypt(txtInputFile.Text)
                MessageBox.Show("Đã giải mã file hoàn tất!", "Thông báo");
                File.Delete(txtOutputFile.Text);
            }
            gch.Free();
            File.Delete("temp1.tmp");
        }
Пример #3
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            GCHandle gch = GCHandle.Alloc(txtPassword.Text, GCHandleType.Pinned);

            AESEncryptDecrypt.FileEncrypt(txtInputFile.Text, txtPassword.Text);
            File.WriteAllText("encrypted_files.dat", txtPassword.Text);
            AESEncryptDecrypt.FileEncrypt("encrypted_files.dat", "pass123456");
            File.Delete("encrypted_files.dat");
            AESEncryptDecrypt.FileEncrypt(txtInputFile.Text, txtPassword.Text);
            File.WriteAllText("fileIn.txt", txtInputFile.Text);
            txtOutputFile.Text = txtInputFile.Text.ToString() + ".aes";
            File.WriteAllText("fileOut.txt", txtOutputFile.Text);
            File.Delete(txtInputFile.Text);
            gch.Free();
        }
Пример #4
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (txtName.Text == "")
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin cho trường Họ Tên!", "Thông báo");
     }
     if (txtEmail.Text == "")
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin cho trường Email!", "Thông báo");
     }
     else if (txtName.Text != "" || txtEmail.Text != "")
     {
         File.WriteAllText("configName.cfg", txtName.Text);
         File.WriteAllText("configEmail.cfg", txtEmail.Text);
         AESEncryptDecrypt.FileEncrypt("configName.cfg", "cVEEdRMrnJ");
         AESEncryptDecrypt.FileEncrypt("configEmail.cfg", "Lm6NzzftiB");
         Form1 frmMain = new Form1();
         frmMain.Show();
         File.Delete("configName.cfg");
         File.Delete("configEmail.cfg");
     }
 }