我怎样才能哈希在C#中使用PBKDF2 HMAC SHA-256和SHA-512的密码盐和迭代? [英] How can I hash passwords with salt and iterations using PBKDF2 HMAC SHA-256 or SHA-512 in C#?

查看:2692
本文介绍了我怎样才能哈希在C#中使用PBKDF2 HMAC SHA-256和SHA-512的密码盐和迭代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一个解决方案或方法,让我加入盐和控制迭代次数。天然Rfc2898DeriveBytes基于HMACSHA1。理想情况下,使用SHA-256或SHA-512将使系统未来的证明。

I would like to find a solution or method that will allow me to add salt and control the number of iterations. The native Rfc2898DeriveBytes is based on HMACSHA1. Ideally, using SHA-256 or SHA-512 will make the system future proof.

这是到目前为止,我已经找到了最好的例子:<一href=\"http://jmedved.com/2012/04/pbkdf2-with-sha-256-and-others/\">http://jmedved.com/2012/04/pbkdf2-with-sha-256-and-others/但是当我与SHA-256运行它它实际上比SHA-512慢。我用64K迭代,盐和不同长度相同的密码来比较GUID。

This is the best example I have found so far: http://jmedved.com/2012/04/pbkdf2-with-sha-256-and-others/ but when I ran it with SHA-256 it was actually slower than with SHA-512. I used 64k iterations, a guid for salt and different same length passwords to compare.

我也发现了此解决方案: http://sourceforge.net/projects/pwdtknet/ 里面有完整的源代码code可用。这似乎是更加健壮。

I also found this solution: http://sourceforge.net/projects/pwdtknet/ which has full source code available. It seems to be more robust.

到目前为止,我无法从他们每个人得到的结果相同。

So far I am not able to get the same output from each of them.

推荐答案

该PWDTK.NET库(的http:/ /sourceforge.net/projects/pwdtknet/ )似乎是唯一的实施我可以发现,确实PBKDF2 HMAC SHA-512和允许的盐和迭代。我一直没能找到测试向量PBKDF2 HMAC SHA-512来测试。

The PWDTK.NET library (http://sourceforge.net/projects/pwdtknet/) seems to be the only implementation I can find that does PBKDF2 HMAC SHA-512 and allows for salt and iterations. I have not been able to locate test vectors for PBKDF2 HMAC SHA-512 to test with.

我很惊讶,有没有更多的开发者那里已经用这个。

I am surprised that there are not more devs out there using this already.

不回答我自己的问题的大风扇,但由于意见退化成一个关于速度的讨论并没有其他人还没有回答,我还不如。

Not a big fan of answering my own questions, but since the comments degraded into a discussion about speed and no one else has answered yet, I might as well.

感谢所有谁评论说。

这篇关于我怎样才能哈希在C#中使用PBKDF2 HMAC SHA-256和SHA-512的密码盐和迭代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆