首页 > 代码库 > ASP.NET实现MD5加密和SHA1加密

ASP.NET实现MD5加密和SHA1加密

MD5加密和SHA1加密的命名空间是在using System.Web.Security;

/// <summary>
/// 返回加密字符串
/// </summary>
/// <param name="content">要加密的字符串</param>
/// <param name="Type">加密类型,默认MD5,其它值SHA1</param>
/// <returns></returns>
public string GetMd5(string content,string Type="MD5")
{
if(Type!="MD5")
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(content,"SHA1");
}
return FormsAuthentication.HashPasswordForStoringInConfigFile(content,"MD5");
}

ASP.NET实现MD5加密和SHA1加密