• .net中MD5过时,使用新的MD5方法


    原有项目的MD5算法提示过时,形如:return FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5")

    使用新的MD5方法。

     public class MD5Helper
        {
            /// <summary>
            /// 推荐
            /// 默认大写 32位加密
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public string GetMd5_32(string str)
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bytes = Encoding.UTF8.GetBytes(str);
                string result = BitConverter.ToString(md5.ComputeHash(bytes));
                return result.Replace("-", "");
            }
    
            /// <summary>
            /// 默认大写 16位加密
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public string GetMd5_16(string str)
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bytes = Encoding.UTF8.GetBytes(str);
                string result = BitConverter.ToString(md5.ComputeHash(bytes), 4, 8);
                return result.Replace("-", "");
            }
        }

    引用:

    https://blog.csdn.net/u011127019/article/details/51384246

  • 相关阅读:
    设置Centos7会话超时时间
    Shell浮点运算
    Maven 同一依赖多版本共存
    Java根据模板生成word
    Java条形码生成
    arcgis for js 4.x 悬浮显示popup
    tomcat 跨域配置
    Mysql8.0 版本 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',报错
    volatile
    synchronized
  • 原文地址:https://www.cnblogs.com/loge/p/16141151.html
Copyright © 2020-2023  润新知