?? form1.cs
字號:
?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;
namespace XorCry
{
public partial class Form1 : Form
{
Cry.Crypt Cry = new Cry.Crypt();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "請選擇要加密的文件";
openFileDialog1.Filter = "All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.FileName = "*.*";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
//FileStream fs = new FileStream(this.openFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
//BinaryReader r = new BinaryReader(fs);
//string bx = "";
//byte buffer;
//try
//{
// buffer = r.ReadByte();
// bx = buffer.ToString();
// buffer = r.ReadByte();
// bx += buffer.ToString();
//}
//catch (Exception exc)
//{
// //Log.WriteError("選擇文件出異常:" + exc.Message);
// MessageBox.Show("選擇文件出異常:" + exc.Message, "選擇要加密的文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
//r.Close();
//fs.Close();
//if (bx == "7790" || bx == "8297" || bx == "8075")//7790:exe,8297:rar,8075:pk
//{
// xx = true;
//}
//if (bx == "112105")
//{
try
{
Cry.CryptFile(this.openFileDialog1.FileName);
MessageBox.Show("加密成功!", "加密文件", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("加密文件出異常:" + ex.Message, "加密文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//}
//else
//{
//}
}
}
private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "請選擇要解密的文件";
openFileDialog1.Filter = "All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.FileName = "*.*";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
//FileStream fs = new FileStream(this.openFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
//BinaryReader r = new BinaryReader(fs);
//string bx = "";
//byte buffer;
//try
//{
// buffer = r.ReadByte();
// bx = buffer.ToString();
// buffer = r.ReadByte();
// bx += buffer.ToString();
//}
//catch (Exception exc)
//{
// MessageBox.Show("選擇文件出異常:" + exc.Message, "選擇要加密的文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
//r.Close();
//fs.Close();
//if (bx == "7790" || bx == "8297" || bx == "8075")//7790:exe,8297:rar,8075:pk
//{
// xx = true;
//}
//if (bx == "112105")
//{
try
{
Cry.CryptFile(this.openFileDialog1.FileName);
MessageBox.Show("解密成功!", "解密文件", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("解密文件出異常:" + ex.Message, "解密文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//}
//else
//{
//}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -