//原来写在一个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中实现加密功能的代码。通过EncryptPassword方法,根据传入的密码字符串和格式,提供MD5和SHA1两种散列加密算法,大小写敏感,最终返回加密结果。
2058

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



