易截截图软件、单文件、免安装、纯绿色、仅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#正则表达式匹配字符串的方法如下:
1.使用C#中使用正则表达式System.Text.RegularExpressions命名空间;
2.使用C#中使用正则表达式Matches()方法匹配字符串,格式如下:
MatchCollection Matches = Regex.Matches(Str, Pattern, RegexOptions.IgnoreCase | RegexOptions.ExplicitC ......

C#对图片的几种简单处理

又有一段时间没有更新了,缺少学习的热情了。今天贴几个图片处理的小技巧,希望对大家有用:
(1)如何获取.gif图片中的各个帧?
(2)如何获取图片的缩略图?
(3)如何“截取”图片的指定区域?
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
public class ImageHelp ......

C#预处理器指令入门

一、C#预处理器指令入门 #define NET11  //NET11,NET20,(必须放在文件第一行)
using System;
//… …
//… …
//… …

string sBeepType = s.Replace(sKey,"");
#if NET20
int.TryParse(sBeepType,out beepType); //在.net 2.0中才有的方法
#endif
#if ......

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# 设计模式学习一 原则

最近着实忙了一阵子,学习了好多东东都没时间整理,呵呵,总算是要放假了,可以好好归纳归纳了。
设计模式的学习是一个任重而道远的过程了,^_^,要好好总结,总结的目的是让自己好好记住,记住的目的是便于理解,而理解的最终目的是应用,O(∩_∩)O~ 而设计模式也往往是应用的一种重构,循环往复,生生不息啊... .. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号