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.
在 WebSecurity
s SimpleMembershipProvider
中使用 PBKDF2 算法,随机 salt 由 StaticRandomNumberGenerator
生成并存储在密码字段中哈希:
In WebSecurity
s 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
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01