C# 有SHA1的加密类吗?像MD5那样

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:17:39
如题

C# 可以用就有MD5的加密类,呵呵

public static string MD5(string str, int code)
{
if (code == 16) //16位MD5加密(取32位加密的9~25字符)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToUpper().Substring(8, 16);
}
else//32位加密
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToUpper();
}
}