我是靠谱客的博主 复杂红牛,这篇文章主要介绍使用MD5加密,现在分享给大家,希望可以做个参考。

类库需要使用md5加密方法

//需要的命名空间

 

using System.Security.Cryptography;

 

 public string Encryption(string pwd)
        {
            MD5 md5 = MD5.Create();

            StringBuilder builder = new StringBuilder();

            byte[] md5Bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(pwd));

            for (int i = 0; i < md5Bytes.Length; i++)
            {
                builder.AppendFormat("{0:X2}", md5Bytes[i]);
            }

            return builder.ToString();
        }

----------------------------------------------------------------------------------------------------------

web Form 使用md5 加密方法

//需要的命名空间

using System.Web.Security;

 public string Encryption(string pwd)
        {

           System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5").ToUpper();

        }

最后

以上就是复杂红牛最近收集整理的关于使用MD5加密的全部内容,更多相关使用MD5加密内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(109)

评论列表共有 0 条评论

立即
投稿
返回
顶部