//引用命名空间
using System.Web.Security;
//MD5加密后长度是32位
FormsAuthentication.HashPasswordForStoringInConfigFile("abc","md5")
//SH1加密后长度是40位
FormsAuthentication.HashPasswordForStoringInConfigFile("abc", "sha1")
//例子:
public string EncryptStr(string PWD, int Format)
{
string str = "";
switch (Format)
{
case 0:
str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "SHA1");
break;
case 1:
str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "MD5");
break;
}
return str;
}
时间: 2024-09-21 19:53:36