博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C#中 MD5加密

Posted on 2008-09-23 21:37  烈火123  阅读(101)  评论(0编辑  收藏  举报
  1. //第一种加密
  2. string str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("密码""MD5");
  3. //第二种加密
  4. //引入命名空间
  5. using System.Text;
  6. using System.Security.Cryptography;
  7. MD5 md5 = MD5CryptoServiceProvider.Create();
  8. byte[] data = Encoding.UTF8.GetBytes("密码");
  9. byte[] newdata = md5.ComputeHash(data);
  10. string str = BitConverter.ToString(newdata);