/// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="strSource">需要加密的明文</param>
        /// <returns>返回32位加密结果</returns>
        public static string Get_MD5(string strSource, string sEncode)
        {
            //new 
            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

            //获取密文字节数组
            byte[] bytResult = md5.ComputeHash(System.Text.Encoding.GetEncoding(sEncode).GetBytes(strSource));

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

            string strResult = BitConverter.ToString(bytResult);

            //BitConverter转换出来的字符串会在每个字符中间产生一个分隔符,需要去除掉 
            strResult = strResult.Replace("-", "");

            return strResult.ToLower();
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2021-04-05
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-08-07
  • 2022-12-23
  • 2021-09-15
  • 2021-05-18
  • 2021-06-24
  • 2022-12-23
相关资源
相似解决方案