Bcrypt for password hashing because it is slow?

我只是一个虾纸丫 提交于 2020-01-01 09:07:14

问题


I read today on not-implemented.com :

Sha-256 should be chosen in most cases where a high speed hash function is desired. It is considered secure with no known theoretical vulnerabilities and it has a reasonable digest size of 32 bytes. For things like hashing user password, though, a function designed to be slow is preferred: a great one is bcrypt.

Can somebody explain the last sentence :

For things like hashing user password, though, a function designed to be slow is preferred: a great one is bcrypt.

I don't say it's not correct, my question is simply:

Why it is preferred for hashing user password to use a slow function ?


回答1:


Because if it takes more time to hash the value, it also takes a much longer time to brute-force the password.

Keep in mind that slow means that it requires more computing power. The same goes for when a potential hacker tries to brute-force a password.




回答2:


On your side, the password hash needs to be computed rather rarely. But an attacker who tries to brute force a password from a stolen hash, relies on computing as many hashes as possible.

So, if your login now takes 100 ms instead of 0.1 (probably less) that's not really a problem for you. But it makes a huge difference for an attacker if he needs 2000 days to break a password instead of 2 days.

bcrypt is designed to be slow and not to allow any shortcut.




回答3:


It takes more effort to brute force attack the password. The slower the algorithm, the less guesses can be made per second. The extra time won't be noticed by a user of the system, but will make it harder to crack the password.




回答4:


Brute force a hash password?. It's easy to say than done.

If the passwords are not using a SALT then it is possible to break it, no matter the kind of encryption (because we could use a dictionary / pre-calculated hash attack).

The speed of the algorithm means nothing, it's just a myth that some people are spreading for the wrong reasons.

For example the next example:

Our hash is generated with the next formula:

 MD5(SALT+MD5(SALT+VALUE))

Even if we could generate every possible combination of md5 in a split of a second, how we know if we found the right value?. And the answer is no, it's not possible. MD5 (or sha) doesn't check if the value is right or not, it simply generates a sequence of values and nothing more.

We could try a force brute attack if and only if we have a way to determine if our hash generated match some criteria. These criteria could be a dictionary and it means a slow process too and only if we could find some criteria.



来源:https://stackoverflow.com/questions/15763086/bcrypt-for-password-hashing-because-it-is-slow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!