我想修改用户密码,然后在用此方法加密,但不知道怎么调用,请帮帮忙
public static string md5(string str, int code)
{
string strEncrypt = string.Empty;
if (code == 16)
{
strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);
} if (code == 32)
{
strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
} return strEncrypt;
}
public static string md5(string str, int code)
{
string strEncrypt = string.Empty;
if (code == 16)
{
strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);
} if (code == 32)
{
strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
} return strEncrypt;
}
类名.md5("xxx",32); //类名是指这个方法所在的类;xxx是传入的加密字符串,32或16一个是原生的md5加密,一个在此基础上又进行了字符串截取
select RIGHT(sys.fn_varbintohexstr(hashbytes('md5','123456')),32) --32位
select substring(sys.fn_varbintohexstr(hashbytes('md5','123456')),8,16)--16位给个数据库加密的代码。你可以用来更新。更新后,注意登陆
然后查询时u_pwd是加密的,在.asp.net里面怎么调用MD5的加密方法