163K网站系统官方论坛's Archiver

cad 发表于 2007-2-16 18:17

.net教程:asp.net中的md5加密

[size=3]其实在asp.net编程中,不用调用md5.asp来加密数据。在dotnet中有自带的类:system.web.security.hashpasswordforstoringinconfigfile()
public string md5(string str,int code)
{
if(code==16) //16位md5加密(取32位加密的9~25字符)
{
return system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(str,"md5").tolower().substring(8,16) ;
}
if(code==32) //32位加密
{
return system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(str,"md5").tolower();
}
return "00000000000000000000000000000000";

}



[/size]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.