old_flsystem/类库/HttpHelper2.1/Helper/MD5Helper.cs

34 lines
1021 B
C#
Raw Permalink Normal View History

2022-09-20 03:10:29 +00:00
using System.Web.Configuration;
using System.Web.Security;
namespace CsharpHttpHelper.Helper
{
/// <summary>
/// md5操作相关 Copyrighthttp://www.httphelper.com/
/// </summary>
internal class MD5Helper
{
/// <summary>
/// 传入明文返回用MD5加密后的字符串
/// </summary>
/// <param name="str">要加密的字符串</param>
/// <returns>MD5加密后的字符串</returns>
internal static string ToMD5_32(string str)
{
string passwordFormat = FormsAuthPasswordFormat.MD5.ToString();
return FormsAuthentication.HashPasswordForStoringInConfigFile(str, passwordFormat);
}
/// <summary>
/// 传入明文返回用SHA1密后的字符串
/// </summary>
/// <param name="str">要加密的字符串</param>
/// <returns>SHA1加密后的字符串</returns>
internal static string ToSHA1(string str)
{
string passwordFormat = FormsAuthPasswordFormat.SHA1.ToString();
return FormsAuthentication.HashPasswordForStoringInConfigFile(str, passwordFormat);
}
}
}