易截截图软件、单文件、免安装、纯绿色、仅160KB

C# 加密-TripleDES

TripleDES
属对称加密,对称加密在加密和解密时都使用相同的密钥,速度快。
TripleDESCryptoServiceProvider 的名称空间是:
System.Security.Cryptography
byte[] plaintextBuffer = System.Text.Encoding.UTF8.GetBytes("明文");
//加密
TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
ICryptoTransform transform = tripleDES.CreateEncryptor();
byte[] cipherTextBuffer = transform.TransformFinalBlock(plaintextBuffer, 0, plaintextBuffer.Length);
lbl.Text = Convert.ToBase64String(cipherTextBuffer) + "<br />";
transform.Dispose();
//解密
TripleDESCryptoServiceProvider tripleDES2 = new TripleDESCryptoServiceProvider();
ICryptoTransform transform2 = tripleDES2.CreateDecryptor(tripleDES.Key, tripleDES.IV);
byte[] decryption = transform2.TransformFinalBlock(cipherTextBuffer, 0, cipherTextBuffer.Length);
lbl.Text += System.Text.Encoding.UTF8.GetString(decryption) + "<br />";
transform2.Dispose();
解密时,使用加密的 Key 和 IV。


相关文档:

asp.net(C#)中文乱码问题

asp.net默认的编码是UTF-8
js文件里的编码也是UTF-8
当你要在aspx页面上进行传中文参数时会出现乱码
<-----request.aspx--接收参数页----->
<----response.aspx--传送参数页----->
例一:<a href="request.aspx?str=中国人"></a>
解决办法一:
1.可以和改webconfig的编码 如:
   ......

使用C#正则表达式匹配相关字符串

C#正则表达式匹配字符串的方法如下:
1.使用C#中使用正则表达式System.Text.RegularExpressions命名空间;
2.使用C#中使用正则表达式Matches()方法匹配字符串,格式如下:
MatchCollection Matches = Regex.Matches(Str, Pattern, RegexOptions.IgnoreCase | RegexOptions.ExplicitC ......

c# virtual虚函数的new、override实现

c#中基类(父类)中的某方法若想在派生类(子类)中被重写(override),必须将基类中的方法定义为virtual,即虚函数。
若派生类将方法修饰为new,即有意隐藏基类中的方法。
下面看一组代码:
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
......

C#开发实例

c#改变系统鼠标
---------------------------------------------------------------------------------------------------
using System.Runtime.InteropServices;
 
[DllImport("User32.DLL")]
public static extern bool SetSystemCursor(IntPtr hcur, uint id);
public const uint OCR_NORMAL = 32512;
publ ......

C# 加密-RSA

RSA
属不对称加密,使用一个公钥一个私钥,公钥可以公开用以加密,私钥严格保密用于解密,RSA 适合于数据量不大的加密,比如加密对称加密的密钥。
RSACryptoServiceProvider
的名称空间是:
System.Security.Cryptography
RSACryptoServiceProvider rsaSend = new RSACryptoServiceProvider();
string plaintext = ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号