C#帮助类:MD5加密
1 /// <summary> 2 /// MD5加密 3 /// </summary> 4 public class Md5 5 { 6 /// <summary> 7 /// MD5加密 8 /// </summary> 9 /// <param name="str">加密字符</param> 10 /// <param name="code">加密位数16/32</param> 11 /// <returns></returns> 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 }
念念不忘,必有回响。技术成就梦想!