using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Security.Cryptography;
|
using System.Text;
|
|
namespace IStation.Untity
|
{
|
public class Md5Cryption
|
{
|
/// <summary>
|
/// 32位MD5加密
|
/// </summary>
|
/// <param name="msg">需要加密的文本</param>
|
/// <param name="encoding">加密的编码</param>
|
public static string Encrypt32(string msg, Encoding encoding = null)
|
{
|
using (MD5 mi = MD5.Create())
|
{
|
if (encoding == null)
|
encoding = Encoding.UTF8;
|
byte[] buffer = encoding.GetBytes(msg);
|
//开始加密
|
byte[] newBuffer = mi.ComputeHash(buffer);
|
StringBuilder sb = new StringBuilder();
|
for (int i = 0; i < newBuffer.Length; i++)
|
{
|
sb.Append(newBuffer[i].ToString("x2"));
|
}
|
return sb.ToString();
|
}
|
}
|
|
|
|
|
}
|
}
|