1 ///
2 /// MD5加密
3 ///
4 public class Md5
5 {
6 ///
7 /// MD5加密
8 ///
9 /// 加密字符
10 /// 加密位数16/32
11 ///
12 public static string md5(string str, int code)
13 {
14 string strEncrypt = string.Empty;
15 if (code == 16)
16 {
17 strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);
18 }
19
20 if (code == 32)
21 {
22 strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
23 }
24
25 return strEncrypt;
26 }
27 }