StringEx

static class StringEx
    {
        public static string MD5(this String str)
        {
            byte[] bytes = new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(str));
            string result = String.Empty;
            for (int i = 0; i < bytes.Length; i++)
            {
                result += bytes[i].ToString("x").PadLeft(2, '0');
            }
            return result;
        }
    }

 

posted @ 2015-01-05 14:01  Old  阅读(349)  评论(0编辑  收藏  举报