获取字符串的md5值

/**
 * author:Anby
 * use:Get md5 
 * time:2013-4-26
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace BLL
{ 
    public static class MD5Helper
    {

        public static string getMd5(string message)
        {
            MD5 md5 = MD5.Create();
            byte[] buffter = System.Text.Encoding.UTF8.GetBytes(message);
            byte[] md5Buf = md5.ComputeHash(buffter);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < md5Buf.Length; i++)
            {
                sb.Append(md5Buf[i].ToString("x2"));
            }
            return sb.ToString();
        }
    }
}

  

posted @ 2013-05-09 20:57  尼姑哪里跑  阅读(247)  评论(0编辑  收藏  举报