//原来写在一个webservice里所以有后面的者一串[WebMethod(Description="提供两种散列加密算法:MD5、SHA1。大小写敏感。")]
public string EncryptPassword(string PasswordString,string PasswordFormat)
{
string result="";
switch(PasswordFormat)
{
case "SHA1":
result=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"SHA1");
break;
case "MD5":
result=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"MD5");
break;
default:
result="";
break;
}
return result;
}
public string EncryptPassword(string PasswordString,string PasswordFormat)
{
string result="";
switch(PasswordFormat)
{
case "SHA1":
result=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"SHA1");
break;
case "MD5":
result=FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"MD5");
break;
default:
result="";
break;
}
return result;
}
博客展示了在WebService中实现加密功能的代码。提供了两种散列加密算法,即MD5和SHA1,且大小写敏感。通过传入密码字符串和加密格式,根据不同格式进行相应加密并返回结果。
2060

被折叠的 条评论
为什么被折叠?



