易截截图软件、单文件、免安装、纯绿色、仅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#的动态类型来实现与rails类似的元编程(1)

熟悉ruby on rails的开发员都知道,在ruby中,有一个很重要的特性,就是能够实现元编程,特别是在用于开发Web应用的rails框架中,用的特别多。在rails中,要创建一个动态方法并与数据库表字段相关联,主要的的步骤大概有这些:
1、首先配置好数据库的连接。
2、创建一个ActiveRecord模型,这个模型与数据库的表名称有一定 ......

C# 加密-MD5 和 SHA1

在 ASP.NET 中可以非常方便地执行 MD5
或 SHA1 加密。
<%@ Import Namespace="System.Web.Security" %>
FormsAuthentication.HashPasswordForStoringInConfigFile
只需要两步,第一步引入名称空间
(该名称空间也可以省略引用),第二步执行加密函数。
FormsAuthentication.HashPasswordForStoringI ......

C# 加密-散列算法

创建散列码的方法非常多,即使是同一种散列算法也可以通过许多类来实现,前面章节介绍的算一种,下面再介绍一种。以 SHA1
为例:
string plaintext = "明文";
byte[] srcBuffer = System.Text.Encoding.UTF8.GetBytes(plaintext);
HashAlgorithm hash = HashAlgorithm.Create("SHA1"); //将参数换 ......

C# 加密-RSA 高级

RSA
实际应用中是:接收方产生公钥和私钥,发送方用其公钥加密,再把加密后的内容发送给接收方。
CspParameters
的名称空间是:
System.Security.Cryptography
CspParameters cpSend = new CspParameters(); //Csp = Cryptography Service Provider
CspParameters cpReceive = new CspParameters();
cpSend.KeyCon ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号