zoukankan      html  css  js  c++  java
  • MD5和SHA1加密

     //MD5特殊加密
            public static string MD51(string password)
            {
                string strResult = ""
                MD5 md5 = System.Security.Cryptography.MD5.Create();
                byte[] byteresult = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
                for (int i = 0; i < byteresult.Length; i++)
                {
                    strResult += byteresult[i].ToString();

                }
                return strResult;
            }

            public static string Get_MD5_Method1(string strSource)
            {
                //new
                MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                //获取密文字节数组
                byte[] bytResult = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(strSource));

                //转换成字符串,并取9到25位
               
                string strResult = BitConverter.ToString(bytResult, 4, 8);
                //转换成字符串,32位
                //string strResult = BitConverter.ToString(bytResult);

                //BitConverter转换出来的字符串会在每个字符中间产生一个分隔符,需要去除掉
                strResult = strResult.Replace("-""");
                return strResult;
            }
            //SHA1加密
            public static string EncryptPassword(string password) 
            {
                string s="";
                UnicodeEncoding encoding = new UnicodeEncoding();
                byte[] hashBytes = encoding.GetBytes(password);
                SHA1 sha1 = new SHA1CryptoServiceProvider();
                byte[] cryptPassWord = sha1.ComputeHash(hashBytes);
                for (int i = 0; i < cryptPassWord.Length; i++)
                {
                    s += cryptPassWord[i].ToString();
                }
                    return s;
            }
  • 相关阅读:
    ajax上传文件
    nginx location指令详解
    总结php删除html标签和标签内的内容的方法
    useBuiltIns: 'usage'
    uni-app如何页面传参数的几种方法总结
    基于 schema 的数据校验
    canvas时点击事件和长按冲突
    vue 下载文件流,后台是get方式 ,并且导出出现excel乱码问题
    uni-app canvas 实现文字居中
    git reflog 回退
  • 原文地址:https://www.cnblogs.com/houziwty/p/2215443.html
Copyright © 2011-2022 走看看