MD5

#region MD5加密
        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="Text">要加密的字符串</param>
        /// <returns>string</returns>
        public  static  string  MD5(string  Text)
        {
            byte[]  buffer  =  System.Text.Encoding.Default.GetBytes(Text);
            try
            {
                System.Security.Cryptography.MD5CryptoServiceProvider  check;
                check  =  new  System.Security.Cryptography.MD5CryptoServiceProvider();
            
                byte[]  somme  =  check.ComputeHash  (buffer);
                string  ret  =  "";
                foreach  (byte  a  in  somme)
                {
                    if  (a<16)
                        ret  +=  "0"  +  a.ToString  ("X");
                    else
                        ret  +=  a.ToString  ("X");
                }
                return  ret  ;
            }
            catch  
            {
                throw;
            }
        }
        #endregion
posted @ 2012-05-04 17:29  一个土豆一棵青菜  阅读(300)  评论(0编辑  收藏  举报