c# - 使用 libsodium-net 时,我不需要生成和存储盐吗?

标签 c# cryptography libsodium

注意我不是加密专家(这就是我使用像 NaCl 这样的库的原因)。

根据我所读到的有关该主题的内容,在数据库中存储用户密码的最安全方法是存储哈希值和用于生成该哈希值的盐。我决定为此目的使用 libsodium-net,但现在我在主题中留下了一个问题:我不需要生成和存储盐吗?我问是因为 libsodium-net 包含这些功能:

// this uses the default Strength.Interactive hashing algorithm
var hash = PasswordHash.ScryptHashString(password);
var isValid = PasswordHash.ScryptHashStringVerify(hash, password);

在生成或验证散列时似乎不需要使用盐。事实上,没有接受盐的 ScryptHashString 和 ScryptHashStringVerify 的重载方法。我觉得我在这里遗漏了一些明显的东西。我是吗?或者 libsodium-net 是否不需要盐?

最佳答案

答案在 documentation 中.从 PasswordHash.ScriptHashString(password) 返回的字符串包含盐(和几个其他参数),因此无需单独存储盐。

关于c# - 使用 libsodium-net 时,我不需要生成和存储盐吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35871675/

相关文章:

c# - Xamarin : Android : System. UnauthorizedAccessException:拒绝访问路径

ubuntu - 如何从 Dieharder 测试套件中获取随机数?

密码学。英语 "normal text"?

python - 值错误: Ciphertext length must be equal to key size

php - 修复损坏的 libsodium php 安装 Ubuntu Xenial

node.js - 在 Node 中使用 libsodium.crypto_pwhash (Argon2)

c# - OpenXML SDK - Excel 更改单元格格式 - C#

c# - Silverlight 中的异步套接字连接

c# - 如何调用IML上的确认对话框?

c# - 在生产 Azure Service Fabric 集群中找不到 libsodium-64.dll