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

C# 加密-Rijndael

Rijndael
属对称加密,对称加密在加密和解密时都使用相同的密钥。2000 年 10 月,NIST 选择 Rijndael(发音为 "Rhine dale")作为 AES 算法,用以取代 DES。
Rijndael 的名称空间是:
System.Security.Cryptography
byte[] plaintextBuffer = System.Text.Encoding.UTF8.GetBytes("明文");

//加密
Rijndael rijndael = Rijndael.Create();
ICryptoTransform transform = rijndael.CreateEncryptor();
byte[] cipherTextBuffer = transform.TransformFinalBlock(plaintextBuffer, 0, plaintextBuffer.Length);
lbl.Text = Convert.ToBase64String(cipherTextBuffer) + "<br />";
transform.Dispose();

//解密
Rijndael rijndael2 = Rijndael.Create();
ICryptoTransform transform2 = rijndael2.CreateDecryptor(rijndael.Key, rijndael.IV);
byte[] decryption = transform2.TransformFinalBlock(cipherTextBuffer, 0, cipherTextBuffer.Length);
lbl.Text += System.Text.Encoding.UTF8.GetString(decryption) + "<br />";
transform2.Dispose();
解密时,使用加密的 Key 和 IV。


相关文档:

C#实现文件关联

和其他语言一样,C#实现文件关联同样需要直接操作注册表,即按规则分别设置文件扩展名,文档类型说明,友好名称,图标,调用方法等键值即可,网上随便查查就可以写出以下的代码。 using Microsoft.Win32; RegistryKey key = Registry.ClassesRoot.OpenSubKey(".jb");
if (key == null)
{
 ......

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#的动态类型来实现与rails类似的元编程(1)

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

C#自动数据库代码生成的思路

C#操作数据库,写来写去就那么几句套话,烦。尽管有SqlHelper之类的辅助类,但还是有一堆参数要自己填,继续烦。最近有朋友问起自动代码生成工具的原理,那今天就说说我的思路吧。我只会MS SQL SERVER,所以就只拿它说事儿了。
其实大的思路很简单,获取数据库中的比较原子的对象,比如字段、参数等,并找出数据库各字段类 ......

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号