本来我也以为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
代码如下,大家执行一下就知道了,我就不多说了。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10748419/viewspace-990781/ ,如需转载,请注明出处,否则将追究法律责任。