using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
using System.Security.Cryptography;
namespace EncryptionAndDecryption
{
public partial class MainForm : Form
{
// 初始化默认选择项
private bool BKaisa = true;
private bool BMD5 = false;
private bool BDES = false;
/*---------------------工具类编辑部分---------------------------------------*/
/**
* 凯撒位移式加密解密工具类
*/
public class KaiSa
{
// 凯撒位移式加密方法
public static string Encrypt(string text, int MoveCount)
{
// 定义一个空字符串
string encrptString = string.Empty;
// 遍历需要加密的原文
foreach (char c in text)
{
// 如果遍历到的原文字符为Unicode字母类别(即在26个字母内)
if (char.IsLetter(c))
{
// 将遍历到的字符根据位移规则位移指定的数目
char newChar = (char)(c + MoveCount);
// 如果位移以后不是字母了
if (!char.IsLetter(newChar))
{
// 减26即过了Z就从A开始
newChar -= (char)26;
}
// 将字母添加到临时字符串中
encrptString += newChar;
}
else// 如果遍历到的不是26个字母
{
// 按原来的添加
encrptString += c;
}
}