using System;
using System
using System
namespace Common
{
/// <summary>
///Copyright (C)
///File name:Hasher
///Author:邝偉科 Version:
///Description:哈希(不可逆)加密通用類庫函數
/// </summary>
public class Hasher
{
private byte[] _HashKey; //哈希密鑰存儲變量
private string _HashText; //待加密的字符串
public Hasher()
{
//
// TODO: 在此處添加構造函數邏輯
//
}
/// <summary>
/// 哈希密鑰
/// </summary>
public byte[] HashKey
{
set
{
_HashKey=value;
}
get
{
return _HashKey;
}
}
/// <summary>
/// 需要產生加密哈希的字符串
/// </summary>
public string HashText
{
set
{
_HashText=value;
}
get
{
return _HashText;
}
}
/// <summary>
/// 使用HMACSHA
/// </summary>
/// <returns></returns>
public string HMACSHA
{
byte[] HmacKey=HashKey;
byte[] HmacData=System
HMACSHA
CryptoStream cs = new CryptoStream(Stream
cs
cs
byte[] Result=Hmac
return Convert
}
/// <summary>
/// 使用MACTripleDES類產生長度為
/// </summary>
/// <returns></returns>
public string MACTripleDESHasher()
{
byte[] MacKey=HashKey;
byte[] MacData=System
MACTripleDES Mac=new MACTripleDES(MacKey);
byte[] Result=Mac
return Convert
}
/// <summary>
/// 使用MD
/// </summary>
/// <returns></returns>
public string MD
{
byte[] MD
MD
byte[] Result=Md
return Convert
}
/// <summary>
/// 使用SHA
/// </summary>
/// <returns></returns>
public string SHA
{
byte[] SHA
SHA
byte[] Result=Sha
return Convert
}
/// <summary>
/// 使用SHA
/// </summary>
/// <returns></returns>
public string SHA
{
byte[] SHA
SHA
byte[] Result=Sha
return Convert
}
/// <summary>
/// 使用SHA
/// </summary>
/// <returns></returns>
public string SHA
{
byte[] SHA
SHA
byte[] Result=Sha
return Convert
}
/// <summary>
/// 使用SHA
/// </summary>
/// <returns></returns>
public string SHA
{
byte[] SHA
SHA
byte[] Result=Sha
return Convert
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26461.html