using System;
|
using System.Security.Cryptography;
|
using System.Text;
|
|
namespace JumbotCms.API.Tenpay
|
{
|
/// <summary>
|
/// MD5Util µÄժҪ˵Ã÷¡£
|
/// </summary>
|
public class MD5Util
|
{
|
public MD5Util()
|
{
|
//
|
// TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼
|
//
|
}
|
|
/** »ñÈ¡´óдµÄMD5Ç©Ãû½á¹û */
|
public static string GetMD5(string encypStr, string charset)
|
{
|
string retStr;
|
MD5CryptoServiceProvider m5 = new MD5CryptoServiceProvider();
|
|
//´´½¨md5¶ÔÏó
|
byte[] inputBye;
|
byte[] outputBye;
|
|
//ʹÓÃGB2312±àÂ뷽ʽ°Ñ×Ö·û´®×ª»¯Îª×Ö½ÚÊý×飮
|
try
|
{
|
inputBye = Encoding.GetEncoding(charset).GetBytes(encypStr);
|
}
|
catch (Exception ex)
|
{
|
inputBye = Encoding.GetEncoding("GB2312").GetBytes(encypStr);
|
}
|
outputBye = m5.ComputeHash(inputBye);
|
|
retStr = System.BitConverter.ToString(outputBye);
|
retStr = retStr.Replace("-", "").ToUpper();
|
return retStr;
|
}
|
}
|
}
|