你的主页或者你管理的网站有各种密码需要保护,把密码直接放在数据库或者文件中存在不少安全隐患,所以密码加密后存储是最常见的做法。在ASP.NET中实现加密非常容易。.NET SDK中提供了CookieAuthentication类,其中的HashPasswordForStoringInConfigFile方法可直接使用MD5和SHA1算法。例子如下:

 

public void SavePassWord_Click (object sender, System.EventArgs e)
 {
  MD5.Text 
= CookieAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text,"MD5");
  
//SHA1 use CookieAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text,"SHA1");
 }

 

注意:类CookieAuthentication的namespace是System.Web.Security

相关文章:

  • 2021-05-27
  • 2021-11-21
  • 2021-11-21
  • 2022-12-23
  • 2021-09-18
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-07
  • 2021-11-21
  • 2021-11-10
  • 2021-09-16
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案