Stu*_*ent 27 c# passwords asp.net-mvc salt webmatrix
我正在使用WebMatrix,并建立了一个基于"StarterSite"的网站.在这个初学者网站中,您将获得一个很好的基本布局 - 包括注册,登录,忘记密码页等...
我注意到在数据库中"webpages_Membership"表有一个名为"PasswordSalt"的列.创建一些新用户帐户后,此列始终为空.所以我假设没有使用密码盐(甚至不是默认密码).
显然这不是最佳实践,但我似乎无法找到任何文档告诉我如何设置或管理密码盐.
如何使用WebSecurity Helper设置密码salt?
And*_*eas 36
上述答案给人的印象是使用时没有涂抹盐渍WebSecurity
SimpleMembershipProvider
.
事实并非如此.实际上,未使用数据库salt字段,但这并不表示在对密码进行散列时不会生成salt.
在WebSecurity
小号SimpleMembershipProvider
使用PBKDF2 ALGO,通过所产生的所述随机盐StaticRandomNumberGenerator
和存储在与所述散列密码字段:
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);
Run Code Online (Sandbox Code Playgroud)