出处:http://www.kehui.org/index.php?op=article&file=read&aid=16367
本来我也以为System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile中的MD5和常用的一样
可今天一试,结果有很大不同,
比如test,HashPasswordForStoringInConfigFile编码成
C8059E2EC7419F590E79D7F1B774BFE6
而应该是098f6bcd4621d373cade4e832627b4f6
而且不同的机器不同的结果,有些结果正确
一看MSDN的解释,原来是
Given a password and a string identifying the hash type, this routine produces a hash password suitable for storing in a configuration file.
为了和以前的代码兼容和平台兼容,只好自己重新写了MD5的算法,利用System.Security.Cryptography.MD5CryptoServiceProvider
代码如下,大家执行一下就知道了,我就不多说了。
??
??
??
博客指出System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile中的MD5编码结果与常用的不同,且不同机器结果有差异。为实现与以前代码和平台的兼容,博主重新编写了MD5算法,利用System.Security.Cryptography.MD5CryptoServiceProvider。
4494

被折叠的 条评论
为什么被折叠?



