using System.Web.Configuration; using System.Web.Security; namespace CsharpHttpHelper.Helper { /// /// md5操作相关 Copyright:http://www.httphelper.com/ /// internal class MD5Helper { /// /// 传入明文,返回用MD5加密后的字符串 /// /// 要加密的字符串 /// MD5加密后的字符串 internal static string ToMD5_32(string str) { string passwordFormat = FormsAuthPasswordFormat.MD5.ToString(); return FormsAuthentication.HashPasswordForStoringInConfigFile(str, passwordFormat); } /// /// 传入明文,返回用SHA1密后的字符串 /// /// 要加密的字符串 /// SHA1加密后的字符串 internal static string ToSHA1(string str) { string passwordFormat = FormsAuthPasswordFormat.SHA1.ToString(); return FormsAuthentication.HashPasswordForStoringInConfigFile(str, passwordFormat); } } }