引入命名空间using System.Web.Security;
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;
}
这两种加密方式无解密方法,SHA1加密要更长一些