• C# 实现MD5加密处理 MD5 加密


    using System.Security.Cryptography;       //引入命名空间
    using System.Text;        //引入命名空间

        public sealed class MD5Hashing
        {
            private static MD5 md5 = MD5.Create();
            private MD5Hashing()
            {
            }
            /**//// <summary>
            /// 将字符串加密
            /// </summary>
            /// <param name="sourceString">需要加密的字符串</param>
            /// <returns>MD5加密后字符串</returns>

            public static string HashString(string sourceString)
            {
                return HashString("gb2312", sourceString);
            }
            /**//// <summary>
            /// 字符串MD5加密
            /// </summary>
            /// <param name="codeName">编码类型</param>
            /// <param name="sourceString">需要加密的字符串</param>
            /// <returns>MD5加密后字符串</returns>

            public static string HashString(string codeName, string sourceString)
            {
                byte[] source = md5.ComputeHash(Encoding.GetEncoding(codeName).GetBytes(sourceString));
                StringBuilder sBuilder = new StringBuilder();
                for (int i = 0; i < source.Length; i++)
                {
                    sBuilder.Append(source[i].ToString("x"));
                }
                return sBuilder.ToString();
            }
        }

    asp.net通用md5加密

    using System.Web.Security;


    public static string HashString(string sourceString)
        {
           return FormsAuthentication.HashPasswordForStoringInConfigFile(sourceString, "md5");
        }

  • 相关阅读:
    查看web访问日志各url shell
    分页公式
    编译hadoop2.6.0源码
    淘宝微信支付
    nodejs hot deployment
    nwjs
    css小技巧
    webpack babel 相关文章
    nodejs web framework
    swiper
  • 原文地址:https://www.cnblogs.com/hsapphire/p/1705962.html
Copyright © 2020-2023  润新知