Chinaunix首页 | 论坛 | 博客
  • 博客访问: 80527
  • 博文数量: 64
  • 博客积分: 1545
  • 博客等级: 上尉
  • 技术积分: 392
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-23 15:23
文章分类

全部博文(64)

文章存档

2013年(1)

2012年(63)

我的朋友

分类: 嵌入式

2012-11-02 16:18:58

其实在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";

}



阅读(1034) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~