zoukankan      html  css  js  c++  java
  • MD5加密帮助类

    MD5加密帮助类

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Security.Cryptography;
     5 
     6 namespace Components.Helper.Security
     7 {
     8     public class MD5Helper
     9     {
    10         private static string Encrypt_MD5(string AppKey)
    11         {
    12             MD5 MD5 = new MD5CryptoServiceProvider();
    13             byte[] datSource = Encoding.GetEncoding("gb2312").GetBytes(AppKey);
    14             byte[] newSource = MD5.ComputeHash(datSource);
    15             StringBuilder sb = new StringBuilder(32);
    16             for (int i = 0; i < newSource.Length; i++)
    17             {
    18                 sb.Append(newSource[i].ToString("x").PadLeft(2, '0'));
    19             }
    20             string crypt = sb.ToString();
    21             return crypt;
    22         }
    23 
    24         //MD5加密
    25         public static string MD5(string str)
    26         {
    27             //(取32替换若干字符,防破解)
    28             string returnStr;
    29             returnStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToUpper();
    30             returnStr = returnStr.Replace("1", "");
    31             returnStr = returnStr.Replace("3", "");
    32             returnStr = returnStr.Replace("5", "");
    33             returnStr = returnStr.Replace("7", "");
    34             returnStr = returnStr.Replace("9", "");
    35             return returnStr;
    36         }
    37     }
    38 }
    MD5Helper
  • 相关阅读:
    (JS/JQ)与Ajax
    JS与JQ的DOM处理
    正则表达式
    JS事件大全
    CSS(初级)学习笔记
    HTML学习笔记
    leetcode记录——65. 有效数字
    dp专题
    Hackerrank---A stones game
    组合博弈问题
  • 原文地址:https://www.cnblogs.com/HuberyHu/p/5390891.html
Copyright © 2011-2022 走看看