zoukankan      html  css  js  c++  java
  • 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");
        }

  • 相关阅读:
    ssh实现免密码登录和文件传输
    linux后台执行程序相关命令
    orchestrator
    curl下载安装与使用
    goland使用
    mysql集群
    consul理解
    my.cnf
    数据库的表设计
    项目常见面试问题
  • 原文地址:https://www.cnblogs.com/hsapphire/p/1705962.html
Copyright © 2011-2022 走看看