md5加密原文地址:http://lintex.blog.sohu.com/4456438.html
来源:互联网 发布:rds恢复到自建数据库 编辑:程序博客网 时间:2024/05/17 06:12
原文地址:http://lintex.blog.sohu.com/4456438.html
网上很多代码都是这样写的,是要导入“System.Web.Security”命名空间,导入后,仍然不行。我仔细看了看MSDN中的“System.Web.Security”命名空间,始终找不到“CookieAuthentication”类。不知道为什么,找了很多代码都是这样写的,这里换成“FormsAuthentication”类就对了。
这里总结两种使用MD5加密的方法:
第一种方法,比较简单,就是上面这种方法,导入“System.Web.Security”命名空间,再使用FormsAuthentication.HashPasswordForStoringInConfigFile("需要加密的字符串", "MD5"),就行了。“MD5”换成“SHA1”可以使用SHA1算法。
第二种方法,需要用到“System.Security.Cryptography”和“System.Text”命名空间。源代码如下:
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] encryptedBytes = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes("需要加密的字符串")); StringBuilder sb = new StringBuilder(); for (int i = 0; i < encryptedBytes.Length; i++) { sb.AppendFormat("{0:x2}", encryptedBytes[i]); } string 结果 = sb.ToString();关于hash、MD5和SHA1,找了一篇文章,写得不错。http://lintex.blog.sohu.com/4457169.html
- md5加密原文地址:http://lintex.blog.sohu.com/4456438.html
- http://feihuayikuang.blog.sohu.com/139047736.html
- http://qqtornado.blog.sohu.com/
- 接口与抽象类的区别 原文地址:http://blog.vsharing.com/jekkon/A1604115.html
- 原文地址: http://yzxqml.iteye.com/blog/1761540
- vim常用命令( 原文地址 http://dozb.bokee.com/4767885.html)
- VC实现最小化后在系统托盘显示_转http://k1983.blog.sohu.com/47997964.html
- 在ASP.Net中使用FCKeditor http://lywzn.blog.sohu.com/52513094.html
- oracle10G启动(转自http://zsss.blog.sohu.com/13096856.html)
- Reporting Service的小技巧(http://tideyee.blog.sohu.com/34897311.html)
- Android系统触摸屏的校正——http://carvencao.blog.sohu.com/156057534.html
- (转+http://howwe.blog.sohu.com/118403286.html )人在做,天在看
- lseek函数的使用 转载自http://atia.blog.sohu.com/94895919.html
- 关于信噪比SNR【转载】1.http://well3216.blog.sohu.com/96624202.html
- badlam.blog.sohu.com
- 【本文系外部转载,原文地址:http://www.hotels2map.com/blog/?p=160】
- jvm详解(原文地址和jvm所有知识:http://pengjiaheng.iteye.com/blog/518623)
- linux学习步骤(原文:http://hi.baidu.com/fuxy0921/blog/item/da74790f8018a6cc7acbe12d.html)
- LINQ体验(9)--LINQ to SQL语句之Insert/Update/Delete操作
- BizTalk Server 2010 - 使用 WCF Service [ 上篇 ]
- spring原理
- LINQ体验(10)--LINQ to SQL语句之开放式并发控制和事务
- 关于用硬盘安装工具Win6Ins_v1.2.0.62安装时提示缺少hildr.mbr文件的解决办法
- md5加密原文地址:http://lintex.blog.sohu.com/4456438.html
- firedebug调试Jquery(转)
- 云计算学习
- 常见的remoteobject错误
- 多关键字 多关键词查询方案
- Java程序员应该避免犯如下十个错误
- ★★ 编码字符集与Java -Java World乱码问题根源之所在
- 一个程序的产生和运行过程
- 给CheckBox换样式