WebMatrix WebSecurity 密码盐
我正在使用 WebMatrix 并建立了一个基于“StarterSite”的网站。在这个入门网站中,您会得到一个很好的基本布局 - 包括注册、登录、忘记密码页面等...
我注意到在数据库中,“webpages_Membership”表有一列名为“PasswordSalt”。创建几个新的用户帐户后,此列始终保持空白。所以我假设没有使用密码盐(甚至不是默认的)。
显然这不是最佳实践,但是我似乎找不到任何文档告诉我如何设置或管理密码盐。
如何使用 WebSecurity Helper 设置密码盐?
I am using WebMatrix and have built a website based on the "StarterSite". In this starter site you get a nice basic layout - including registration, login, forgot password pages etc...
I've noticed that in the database that the "webpages_Membership" table has a column named "PasswordSalt". After creating a few new user accounts, this column always remains blank. So I'm assuming that no password salt (not even a default one) is in use.
Obviously this is not the best practice, however I cannot seem to find any documentation that tells me how to set or manage the password salt.
How can I set the password salt with the WebSecurity Helper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的答案给人的印象是,使用
WebSecurity
SimpleMembershipProvider
时没有应用加盐。那不是真的。实际上,没有使用数据库盐字段,但这并不表明在对密码进行哈希处理时没有生成盐。
在
WebSecurity
的SimpleMembershipProvider
中,使用 PBKDF2 算法,随机盐由StaticRandomNumberGenerator
生成,并使用哈希值存储在密码字段中:The above answer gives the impression that there is no salting applied when using
WebSecurity
SimpleMembershipProvider
.That is not true. Indeed the database salt field is not used, however this does not indicate that there is no salt generated when hashing the password.
In
WebSecurity
sSimpleMembershipProvider
the PBKDF2 algo is used, the random salt is generated by theStaticRandomNumberGenerator
and stored in the password field with the hash:从 WebMatrix/ASP.NET 网页的 RTM 版本开始,salt 功能/列未使用。
如果您打开网页源代码,您将看到数据库类散布着诸如
...
为了强调而缩短的引用,
肯定有方法可以覆盖和实现此行为,首先是
或
除非您要求,否则不会详细介绍,因为您对 WebMatrix 和模板的使用表明您可能不想乱重写该项目需要大量您自己的 C#/ASP 代码。
As of the RTM release of WebMatrix/ASP.NET Web Pages, the salt feature/column is unused.
If you open up the Web Pages source, you'll see the db classes littered with references like
...
shortened for emphasis
There are definately ways to override and implement this behavior, first being:
or
not going to go into detail there though unless you request, as your usage of WebMatrix and a template suggests you probably don't wanna mess with rewriting a ton of your own C#/ASP code for this project.