bcrypt的.Net实现,它实现了HashAlgorithm?
我希望在我的身份验证库中允许 bcrypt 支持。现在的问题之一是我假设哈希器的类型为HashAlgorithm
。 Bcrypt.net 没有实现此类。另外,它是密封的,所以我必须用它创建我自己的分支并自己修改它。有没有更好的替代方案已经实现了 HashAlgorithm?
I'm looking to allow bcrypt support in my authentication library. One of the problems right now is that I assume that the hasher will be of type HashAlgorithm
. Bcrypt.net does not implement this class. Also, it's sealed so I would have to make my own branch off of it and modify it myself. Are there any better alternatives that already implement HashAlgorithm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
用法:
另外,我添加了一个辅助验证方法,以便您可以验证密码和哈希是否匹配,但如果您只调用默认的 BCrypt.Verify,则可以消除这种情况。
我添加了一些额外的属性,以便您可以在执行哈希之前传递预先计算的盐或工作因子来生成新的盐:
我使用 BCrypt 测试用例“abc”进行了尝试,盐为“$2a$06$” If6bvum7DFjUnE9p2uDeDu”并得到了正确的哈希值。
Try this:
Usage:
Also, I added a helper Verify method so you can verify that the password and hash match, but you can eliminate this if you just call the default BCrypt.Verify.
I added some extra properties so you can pass in a pre-computed salt or a work factor to generate a new salt before you do the hash:
I tried it with the BCrypt test case "abc" with a salt of "$2a$06$If6bvum7DFjUnE9p2uDeDu" and got the correct hash.