是BCrypt在C#中使用一个好的哈希算法?我在哪里可以找到它? [英] Is BCrypt a good hashing algorithm to use in C#? Where can I find it?

查看:1712
本文介绍了是BCrypt在C#中使用一个好的哈希算法?我在哪里可以找到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读,散列密码的时候,很多程序员建议使用BCrypt算法。

I have read that when hashing a password, many programmers recommend using the BCrypt algorithm.

我编程在C#中,如果有人了良好的实施BCrypt都知道是想知道?我发现<一个href=\"http://derekslager.com/blog/posts/2007/10/bcrypt-dotnet-strong-password-hashing-for-dotnet-and-mono.ashx\">this页面,但我真的不知道,如果它是假的或没有。

I am programming in C# and is wondering if anyone knows of a good implementation for BCrypt? I found this page, but I don't really know if it is bogus or not.

我应该知道选择密码散列方案的时候?是BCrypt一个'好'的实施?

What should I be aware of when choosing a password hashing scheme? Is BCrypt a 'good' implementation?

推荐答案

首先,有些条款是很重要的:

First, some terms that are important:

散列 - 采取串并产生一个字符序列的行为是不能要恢复到原始字符串。

Hashing - The act of taking a string and producing a sequence of characters that cannot be reverted to the original string.

对称加密 - (通常只简称加密) - 服用一个字符串转化的字符序列的行为可以通过使用该加密是相同的加密密钥来解密原始字符串。

Symmetric Encryption - (Usually just referred to as 'encryption') - The act of taking a string and producing a sequence of characters that can be decrypted to the original string through the use of the same encryption key that encrypted it.

彩虹表 - 包含特定字符散列的所有变体查找表散列算法。

Rainbow Table - a lookup table that contains all variations of characters hashed in a specific hashing algorithm.

- 前追加到原始字符串一个已知的随机字符串它是散列。

Salt - a known random string appended to the original string before it is hashed.

对于.NET Framework,Bcrypt还没有一个的验证的参考实现。这一点很重要,因为没有办法知道是否有现有的实现存在严重缺陷。你可以在这里得到 BCrypt对.NET的实现。我不知道有足够的了解加密要说它是否是一个好或坏的实现。密码学是一个非常深刻的领域。 不要试图建立自己的加密算法。认真。

For the .NET Framework, Bcrypt does not yet have a verified reference implementation. This is important because there's no way to know if there are serious flaws in an existing implementation. You can get an implementation of BCrypt for .NET here. I don't know enough about cryptography to say whether it's a good or bad implementation. Cryptography is a very deep field. Do not attempt to build your own encryption algorithm. Seriously.

如果你要实现你自己的密码安全性(叹气),那么你需要做几件事情:

If you are going to implement your own password security (sigh), then you need to do several things:


  1. 使用一个相对安全散列算法

  2. 盐之前,每个密码哈希的。

  3. 使用一个独特而长期食盐每个密码和含盐存储与密码。

  4. 要求使用强密码

  1. Use a relatively secure hash algorithm.
  2. Salt each password before it's hashed.
  3. Use a unique and long salt for each password, and store the salt with the password.
  4. Require strong passwords.

不幸的是,即使你做的这一切,一个意志坚定的黑客仍然有可能找出密码,它只是把他很长一段时间。这是你的主要敌人:时间

Unfortunately, even if you do all this, a determined hacker still could potentially figure out the passwords, it would just take him a really long time. That's your chief enemy: Time.

借助 bcrypt算法的工作,因为它需要的幅度五个的订单更长的时间来哈希比MD5 密码; (仍然比AES或SHA-512长得多)。它迫使黑客花费更多的时间来创建一个彩虹表来查找你的密码,使其不太可能,你的密码会在被黑客攻击危险。

The bcrypt algorithm works because it takes five orders of magnitude longer to hash a password than MD5; (and still much longer than AES or SHA-512). It forces the hacker to spend a lot more time to create a rainbow table to lookup your passwords, making it far less likely that your passwords will be in jeopardy of being hacked.

如果你腌制和散列密码,每个盐是不同的,然后潜在的黑客将不得不创建一个彩虹表盐的每个变化,只是有一个彩虹表为一个咸鱼+哈希密码。这意味着,如果你有100万用户,黑客有可能产生百万彩虹表。如果您使用的相同的盐为每一位用户,那么黑客只需要1生成彩虹表成功地入侵您的系统。

If you're salting and hashing your passwords, and each salt is different, then a potential hacker would have to create a rainbow table for each variation of salt, just to have a rainbow table for one salted+hashed password. That means if you have 1 million users, a hacker has to generate 1 million rainbow tables. If you're using the same salt for every user, then the hacker only has to generate 1 rainbow table to successfully hack your system.

如果你不腌制您的密码,那么所有攻击者所要做的就是拉起现有的彩虹表,每个实现在那里(AES,SHA-512,MD5),只是看一个散列相匹配。这已经完成中,攻击者的不需要计算这些彩虹表本身

If you're not salting your passwords, then all an attacker has to do is to pull up an existing Rainbow table for every implementation out there (AES, SHA-512, MD5) and just see if one matches the hash. This has already been done, an attacker does not need to calculate these Rainbow tables themselves.

即使这一切,<一个href=\"http://programmers.stackexchange.com/questions/46716/what-technical-details-should-a-programmer-of-a-web-application-consider-before\">you've一定要使用良好的安全习惯。如果他们能成功地使用在另一个攻击向量(XSS,SQL注入,跨站请求伪造,等人)您的网站,好密码的安全性没有关系。这听起来像一个有争议的说法,但仔细想想:如果我可以通过SQL注入攻击获取您的所有用户信息,或者我可以让你的用户给我自己的cookies通过XSS,的那不要紧,你的密码的安全性有多好

Even with all this, you've got to be using good security practices. If they can successfully use another attack vector (XSS, SQL Injection, CSRF, et. al.) on your site, good password security doesn't matter. That sounds like a controversial statement, but think about it: If I can get all your user information through a SQL injection attack, or I can get your users to give me their cookies through XSS, then it doesn't matter how good your password security is.

其他资源:


  1. 杰夫阿特伍德:<一href=\"http://www.$c$cproject.com/KB/security/SimpleEncryption.aspx?fid=172899&df=90&mpp=10&noise=2&sort=Position&view=Expanded&fr=91\">.NET加密简化(伟大的散列概述)

  2. 杰夫阿特伍德:我只是登录为您

  3. 杰夫阿特伍德:<一href=\"http://www.codinghorror.com/blog/2007/09/youre-probably-storing-passwords-incorrectly.html\">You're大概存储密码不正确

  4. 杰夫阿特伍德:速度散列

  1. Jeff Atwood: .NET Encryption Simplified (great for an overview of hashing)
  2. Jeff Atwood: I just logged in as you
  3. Jeff Atwood: You're probably storing passwords incorrectly
  4. Jeff Atwood: Speed Hashing

注意:请推荐其他的好资源。我必须在数十作者已经读过十数篇,但少写明关于这个问题的杰夫一样。请编辑文章,你找到他们。

Note: Please recommend other good resources. I've must have read a dozen articles by dozens of authors, but few write as plainly on the subject as Jeff does. Please edit in articles as you find them.

这篇关于是BCrypt在C#中使用一个好的哈希算法?我在哪里可以找到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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