WebMatrix WebSecurity PasswordSalt(WebMatrix WebSecurity PasswordSalt)
问题描述
我正在使用 WebMatrix 并基于StarterSite"建立了一个网站.在这个入门网站中,您可以获得一个不错的基本布局 - 包括注册、登录、忘记密码页面等...
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...
我注意到在数据库中webpages_Membership"表有一个名为PasswordSalt"的列.创建几个新用户帐户后,此列始终保持空白.所以我假设没有使用密码盐(甚至不是默认密码).
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.
如何使用 WebSecurity Helper 设置密码盐?
How can I set the password salt with the WebSecurity Helper?
推荐答案
上面的答案给人的印象是使用 WebSecurity SimpleMembershipProvider 时没有应用加盐.
The above answer gives the impression that there is no salting applied when using WebSecurity SimpleMembershipProvider.
那不是真的.确实没有使用数据库 salt 字段,但这并不表示在对密码进行哈希处理时没有生成 salt.
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.
在 WebSecuritys SimpleMembershipProvider 中使用 PBKDF2 算法,随机 salt 由 StaticRandomNumberGenerator 生成并存储在密码字段中哈希:
In WebSecuritys SimpleMembershipProvider the PBKDF2 algo is used, the random salt is generated by the StaticRandomNumberGenerator and stored in the password field with the hash:
byte[] outputBytes = new byte[1 + SALT_SIZE + PBKDF2_SUBKEY_LENGTH];
Buffer.BlockCopy(salt, 0, outputBytes, 1, SALT_SIZE);
Buffer.BlockCopy(subkey, 0, outputBytes, 1 + SALT_SIZE, PBKDF2_SUBKEY_LENGTH);
return Convert.ToBase64String(outputBytes);
这篇关于WebMatrix WebSecurity PasswordSalt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WebMatrix WebSecurity PasswordSalt
基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
