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

C# 加密-散列算法

创建散列码的方法非常多,即使是同一种散列算法也可以通过许多类来实现,前面章节介绍的算一种,下面再介绍一种。以 SHA1
为例:
string plaintext = "明文";
byte[] srcBuffer = System.Text.Encoding.UTF8.GetBytes(plaintext);
HashAlgorithm hash = HashAlgorithm.Create("SHA1"); //将参数换成“MD5”,则执行 MD5 加密。不区分大小写。
byte[] destBuffer = hash.ComputeHash(srcBuffer);
string hashedText = BitConverter.ToString(destBuffer).Replace("-", "");
用的是 HashAlgorithm
这个类,其名称空间是 System.Security.Cryptography
。只用了它的两个方法:Create
和 ComputeHash
,ComputeHash 返回的是 byte[],为了显示这里转换成字符串,转换之后,它和前一节讲的 SHA1 结果是一样的。
也可以用 SHA1Managed
和 SHA1CryptoServiceProvider
,但是我们推荐用本文的方法,因为它不涉及类名,要更改算法,只需要更改 Create 的字符串参数即可。


相关文档:

C#画线控件的开发应用实例解析

C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
    C#画线控件之横线
using System;  
using System.Collections;  
using System.ComponentModel; ......

C#实现文件关联

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

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号