C#.NET史上最全字符串加密/解密/数字签名工具(CryptoHelper.cs)
作者:C/S框架网  发布日期:2017-09-12 20:23:24
  C#.NET史上最全字符串加密/解密/数字签名工具(CryptoHelper.cs)

C# Code:

string text = "www.csframework.com/www.cscode.net C/S框架网测试";

txtResponse.Text = CryptoHelper.ToMD5(text);
MessageBox.Show("ToMD5:" txtResponse.Text);

txtResponse.Text = CryptoHelper.ToSHA256Hash(text);
MessageBox.Show("ToSHA256Hash:" txtResponse.Text);

txtResponse.Text = CryptoHelper.ToSHA512Hash(text);
MessageBox.Show("ToSHA512Hash:" txtResponse.Text);

string privateKey; string publicKey;

CryptoHelper.DSAGetKey(out privateKey, out publicKey);
txtResponse.Text = CryptoHelper.DSASign(text, privateKey);
MessageBox.Show("DSASign:" txtResponse.Text);

bool ss = CryptoHelper.DSAVerify(text, txtResponse.Text, publicKey);
txtResponse.Text = ss ? "验证成功" : "验证失败";
MessageBox.Show("DSAVerify:" txtResponse.Text);

CryptoHelper.RSAGetKey(out privateKey, out publicKey);

txtResponse.Text = CryptoHelper.RSAEncrypt(text, publicKey);
MessageBox.Show("RSAEncrypt:" txtResponse.Text);

txtResponse.Text = CryptoHelper.RSADecrypt(txtResponse.Text, privateKey);
MessageBox.Show("RSADecrypt:" txtResponse.Text);

txtResponse.Text = CryptoHelper.RSASign(text, privateKey);
MessageBox.Show("RSASign:" txtResponse.Text);

bool ok = CryptoHelper.RSAVerify(text, txtResponse.Text, publicKey);
txtResponse.Text = ok ? "验证成功" : "验证失败";
MessageBox.Show("RSAVerify:" txtResponse.Text);

txtResponse.Text = CryptoHelper.TripleDESEncrypt(text, "ABCDEFGHIJKLMNOP", "12345678");
MessageBox.Show(CryptoHelper.TripleDESDecrypt(txtResponse.Text, "ABCDEFGHIJKLMNOP", "12345678"));

txtResponse.Text = CryptoHelper.RijndaelEncrypt(text, "12345678", "12345678");
MessageBox.Show(CryptoHelper.RijndaelDecrypt(txtResponse.Text, "12345678", "12345678"));

txtResponse.Text = CryptoHelper.DESEncrypt(text, "12345678", "12345678");
MessageBox.Show(CryptoHelper.DESDecrypt(txtResponse.Text, "12345678", "12345678"));

//来源:C/S框架网(www.csframework.com) QQ:1980854898


点击下载附件 (VIP会员下载) 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇