日期:2011-05-14  浏览次数:20426 次

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

namespace 对称加密应用
{
 ///
 /// Form1 的摘要说明。
 ///
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.TextBox textBox2;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.Button button2;
  ///
  /// 必需的设计器变量。
 
  private System.Windows.Forms.TextBox textBox3;
  private System.Windows.Forms.OpenFileDialog openfile;
  private System.Windows.Forms.Button button3;
  private System.Windows.Forms.SaveFileDialog savefile;
  private System.Windows.Forms.Button button4;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.CheckBox checkBox1;

  //创建实例
  RijndaelManaged rij = new RijndaelManaged();//
  //全局变量,标记文件的扩展名
  private static string ext=null;
  //标记加密成功与否
  private static bool enresult = false;
  //标记解密成功与否的标记
  private static bool deresult = false;
 
  ///
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  ///
  /// 清理所有正在使用的资源。
  ///
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  ///
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  ///
  private void InitializeComponent()
  {
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.button1 = new System.Windows.Forms.Button();
   this.button2 = new System.Windows.Forms.Button();
   this.textBox3 = new System.Windows.Forms.TextBox();
   this.openfile = new System.Windows.Forms.OpenFileDialog();
   this.button3 = new System.Windows.Forms.Button();
   this.savefile = new System.Windows.Forms.SaveFileDialog();
   this.button4 = new System.Windows.Forms.Button();
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.checkBox1 = new System.Windows.Forms.CheckBox();
   this.SuspendLayout();
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(88, 96);
   this.textBox1.Name = "textBox1";
   this.textBox1.Size = new System.Drawing.Size(168, 21);
   this.textBox1.TabIndex = 0;
   this.textBox1.Text = "";
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(88, 136);
   this.textBox2.Name