引入:using System.Web.Security;
public static string md5(string password, int codeLength) { if (!string.IsNullOrEmpty(password)) { if (codeLength == 0x10) { return FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5").ToLower().Substring(8, 0x10); } if (codeLength == 0x20) { return FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5").ToLower(); } } return string.Empty; } |