using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;namespace DataCrypto
{
/// <summary>
/// 哈希加密类
/// </summary>
public class HashMethod
{
private HashAlgorithm HashCryptoService;
/// <summary>
/// 哈希加密类的构造函数
/// </summary>
public HashMethod()
{
HashCryptoService = new SHA1Managed();
}
/// <summary>
/// 加密方法
/// </summary>
/// <param name="Source">待加密的串</param>
/// <returns>经过加密的串</returns>
public string Encrypto(string Source)
{
byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source);
byte[] bytOut = HashCryptoService.ComputeHash(bytIn);
return Convert.ToBase64String(bytOut);
}
}
}
using System.IO;
using System.Security.Cryptography;
using System.Text;namespace DataCrypto
{
/// <summary>
/// 哈希加密类
/// </summary>
public class HashMethod
{
private HashAlgorithm HashCryptoService;
/// <summary>
/// 哈希加密类的构造函数
/// </summary>
public HashMethod()
{
HashCryptoService = new SHA1Managed();
}
/// <summary>
/// 加密方法
/// </summary>
/// <param name="Source">待加密的串</param>
/// <returns>经过加密的串</returns>
public string Encrypto(string Source)
{
byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source);
byte[] bytOut = HashCryptoService.ComputeHash(bytIn);
return Convert.ToBase64String(bytOut);
}
}
}
http://www.microsoft.com/china/msdn/archives/library/dndotnet/html/callnetfrcom.asp
http://www.tongyi.net/article/20011018/200110182440.shtml
http://blog.yesky.com/Blog/wells/archive/2005/03/18/90951.html