• c# MD5方法总结


         /// <summary>
            /// 32位md5
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static string GetBigMd5(string str)
            {
                string cl = str;
                string pwd = "";
                var md5 = MD5.Create();

                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));

                for (int i = 0; i < s.Length; i++)
                {
                    pwd = pwd + s[i].ToString("X2");
                }

                return pwd;
            }
            /// <summary>
            /// 16位MD5
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static string GetSmallMd5(string str)
            {
                var md5 = new MD5CryptoServiceProvider();
                string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(str)), 4, 8);
                t2 = t2.Replace("-", "");
                return t2;
            }

            private static string Encrypt(string strInput)
            {
                int i;

                int len = strInput.Length;

                string strFont = strInput.Remove(len - 1, 1);
                string strEnd = strInput.Remove(0, len - 1);

                var charFont = strFont.ToCharArray();
                for (i = 0; i < strFont.Length; i++)
                {
                    int intFont = (int)charFont[i] + 3;
                    charFont[i] = Convert.ToChar(intFont);

                }
                strFont = ""; //let strFont  null
                for (i = 0; i < charFont.Length; i++)
                {
                    strFont += charFont[i];
                }
                var strOutput = strEnd + strFont;
                return strOutput;

            }
            private static string Decrypt(string strInput)
            {
                int i;

                string strFont = strInput.Remove(0, 1);
                string strEnd = strInput.Remove(1);

                var charFont = strFont.ToCharArray();
                for (i = 0; i < strFont.Length; i++)
                {
                    int intFont = (int)charFont[i] - 3;
                    charFont[i] = Convert.ToChar(intFont);

                }
                strFont = ""; //let strFont  null
                for (i = 0; i < charFont.Length; i++)
                {
                    strFont += charFont[i];
                }
                string strOutput = strFont + strEnd;
                return strOutput;
            }
  • 相关阅读:
    k8s蓝绿
    nginx总结
    promethues监控 之 TCP连接数
    制作私有ssl证书
    redis命令
    zabbix主机自动发现
    Kubernetes各组件服务重启
    linxu下常用命令
    encodeURIComponent
    查询条件
  • 原文地址:https://www.cnblogs.com/fengyun99/p/1710372.html
Copyright © 2020-2023  润新知