嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
MD5加密
AES加密/解密
DES加密/解密
RSA加密/解密
public Form1()
{
InitializeComponent();
}
/// <summary>
/// MD5转换
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnMD5_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(rtbMd5Base.Text))
{
rtbMd5.Text = SHAHelper.SHAmd5Encrypt(rtbMd5Base.Text);
}
}
/// <summary>
/// md5清空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnMd5Clear_Click(object sender, EventArgs e)
{
rtbMd5.Text = "";
rtbMd5Base.Text = "";
}
/// <summary>
/// AES加密
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAes_Click(object sender, EventArgs e)
{
if (txtAESKey.Text.Length != 32)
{
MessageBox.Show($@"秘钥长度必须32位,当前长度{txtAESKey.Text.Length}");
return;
}
if (string.IsNullOrWhiteSpace(txtAESKey.Text) || string.IsNullOrWhiteSpace(rtbAesBase.Text))
{
MessageBox.Show(@"Please input key and text");
return;
}
rtbAES.Text = AESHelper.AesEncrypt(rtbAesBase.Text, txtAESKey.Text);
}
/// <summary>
/// AES解密
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btndeAES_Click(object sender, EventArgs e)
{
rtbdeAes.Text = "";
if (txtDeKey.Text.Length != 32)
{
MessageBox.Show($@"秘钥长度必须32位,当前长度{txtDeKey.Text.Length}");
return;
}
if (string.IsNullOrWhiteSpace(txtDeKey.Text) || string.IsNullOrWhiteSpace(rtbAES.Text))
{
MessageBox.Show(@"Please input DeKey and text");
return;
}
try
{
rtbdeAes.Text = AESHelper.AesDecrypt(rtbAES.Text, txtDeKey.Text);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
/// <summary>
/// Des加密
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDes_Click(object sender, EventArgs e)
{
if (txtDESkey.Text.Length != 8 || txtDesVar.Text.Length != 8)
{
MessageBox.Show($@"秘钥/向量必须8位,当前秘钥长度{txtDESkey.Text.Length}");
}
if (string.IsNullOrWhiteSpace(txtDESkey.Text) || string.IsNullOrWhiteSpace(txtDesVar.Text) || string.IsNullOrWhiteSpace(rtbDesBase.Text))
{
MessageBox.Show(@"请输入秘钥、向量及待加密文本");
}
DESHelper._KEY = System.Text.Encoding.Default.GetBytes(txtDESkey.Text);
DESHelper._IV = System.Text.Encoding.Default.GetBytes(txtDesVar.Text);
rtbDES.Text = DESHelper.DesEncrypt(rtbDesBase.Text);
}
/// <summary>
/// des解密
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDEDes_Click(object sender, EventArgs e)
{
if (txtDEDES.Text.Length != 8 || txtDesVar.Text.Length != 8)
{
MessageBox.Show($@"秘钥/向量必须8位,当前秘钥长度{txtDESkey.Text.Length}");
}
if (string.IsNullOrWhiteSpace(txtDEDES.Text) || string.IsNullOrWhiteSpace(txtDeVar.Text) || string.IsNullOrWhiteSpace(rtbDES.Text))
{
MessageBox.Show(@"请输入秘钥、向量及待解密文本");
}
DESHelper._KEY = System.Text.Encoding.Default.GetBytes(txtDEDES.Text);
DESHelper._IV = System.Text.Encoding.Default.GetBytes(txtDeVar.Text);
try
{
DES.Text = DESHelper.DesDecrypt(rtbDES.Text);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
/// <summary>
/// RES生成秘钥
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCreateKey_Click(object sender, EventArgs e)
{
string path = "";
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = @"请选择保存文件夹";
dialog.SelectedPath = path;
//dialog.RootFolder = Environment.SpecialFolder.Programs;
if (dialog.ShowDialog() == DialogResult.OK)
{
string foldPath = dialog.SelectedPath;
RSAHelper.GenerateKeys(foldPath);
txtPub.Text = Path.Combine(foldPath, "RSA.Pub");
txtPri.Text = Path.Combine(foldPath, "RSA.Private");
}
}
/// <summary>
/// rsa加密
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRSA_Click(object sender, EventArgs e)
{
//选择文件
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false ;//该值确定是否可以选择多个文件
dialog.Title = @"请选择文件夹";
dialog.Filter = @"Pub文件(*.Pub)|*.Pub";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string file = dialog.FileName;
rtbDeRSA.Text= RSAHelper.Encrypt(rtbRSABase.Text, file);
}
}
private void btnDERSA_Click(object sender, EventArgs e)
{
//选择文件
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;//该值确定是否可以选择多个文件
dialog.Title = @"请选择文件夹";
dialog.Filter = @"Private文件(*.Private)|*.Private";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string file = dialog.FileName;
rtbDERSAold.Text = RSAHelper.Decrypt(rtbDeRSA.Text, file);
}
}