首先新添加一个类文档md5.cs,在引用命名空间下面直接输入下面的代码!
![]()
Code
public class md5
{
public string pwd(string str, int code)
{
if (code == 16)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
else
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
}
}
下面是调用方法!也是直接new一个jiami类出来!然后使用这个类里面的pws方法对paswod进行MD5,16位加密!
![]()
Code
md5 jiami = new md5();
string md5jiami = jiami.pwd(paswod, 16);
下载代码