加密&解密

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;
using  System.IO;
using  System.Security;
using  System.Security.Cryptography;

namespace  Lock_UnLock
{
    
public partial class Form1 : Form
    
{
        

        
public Form1()
        
{
            InitializeComponent();
        }


        
private byte[] sKey;
        
private byte[] sIV;

        
public string key = "";

        
private void button5_Click(object sender, EventArgs e)
        
{
            Application.Exit();
        }


        
private void Form1_Load(object sender, EventArgs e)
        
{
            
this.textBox1.ReadOnly = true;
            
this.textBox2.ReadOnly = true;
            
this.radioButton1.Checked = true;
            
this.label4.Text = DateTime.Now.ToLongDateString();
            
this.textBox3.Text = "安全密匙用于解密文件!";
            
this.textBox3.Focus();
            
int len = textBox3.Text.Length;
            
this.textBox3.SelectionStart = 0;
            
this.textBox3.SelectionLength = len;
        }


        
private void button1_Click(object sender, EventArgs e)
        
{
            
this.openFileDialog1.ShowDialog();
            
string filename = openFileDialog1.FileName;
            
int i = filename.LastIndexOf(".");
            
if (i != -1)
            
{
                
string filetype = filename.Substring(filename.LastIndexOf("."));
                
if (this.radioButton1.Checked)
                
{
                    filename 
= filename.Replace("(解密文件)""");
                    textBox2.Text 
= filename.Substring(0, filename.LastIndexOf(".")) + "(加密文件)" + filetype;
                }

                
else
                
{
                    filename 
= filename.Replace("(加密文件)""");
                    textBox2.Text 
= filename.Substring(0, filename.LastIndexOf(".")) + "(解密文件)" + filetype;

                }

            }

            
if (filename != "")
            
{
                textBox1.Text 
= openFileDialog1.FileName;

            }

        }


        
private void button2_Click(object sender, EventArgs e)
        
{
            
this.saveFileDialog1.ShowDialog();
            
if (saveFileDialog1.FileName != "")
            
{
                
this.textBox2.Text = saveFileDialog1.FileName;
            }

        }


        
private void radioButton1_CheckedChanged(object sender, EventArgs e)
        
{
            
if (radioButton1.Checked == true)
            
{
                
this.button4.Enabled = false;
                
this.button3.Enabled = true;
            }

        }


        
private void radioButton2_CheckedChanged(object sender, EventArgs e)
        
{
            
if (radioButton2.Checked == true)
            
{
                
this.button3.Enabled = false;
                
this.button4.Enabled = true;
            }

        }


        
"加密方法


        
"解密方法


        
"加密


        
"解密
    }

}

  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值