C# MD5加密字符串

时间:2021-01-12 11:08:56   收藏:0   阅读:0
        public string GetMD5(string txt)
        {
            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] frmData = System.Text.Encoding.UTF8.GetBytes(txt);
            byte[] targetData = md5.ComputeHash(frmData);
            string str = null;
            for (int i = 0; i < targetData.Length; i++)
            {
                str = str + targetData[i].ToString("x2");
            }
            return str;
        }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!