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

34 lines
1021 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}