public static string Encrypt(string txt)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(txt));
            
            return BitConverter.ToString(bytes).Replace("-", "");
        }


        public static string Encrypt2(string txt)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(txt));
            StringBuilder sb = new StringBuilder();
            foreach(byte b in bytes)
            {
                sb.Append(b.ToString("X").PadLeft(2,'0'));
            }
            return sb.ToString();
        }

 

 posted on 2016-12-28 10:44  Just_Do  阅读(811)  评论(0编辑  收藏  举报