1

Possible Duplicate:
What's the recommended hashing algorithm to use for stored passwords?

Hello, I've recently been told that common hash functions such as SHA256 are insecure for use as a password hashing function because they are "designed to be fast"(incidentally I asked earlier for faster hashing functions over at programmers.se). So my question, what should be used for websites or other general applications?

Also, secondary question: Is SHA256 really not a good choice for hashing passwords? I kind of don't believe it, but I've heard crazier things be true.

(note: assume all other proper actions are being taken such as unique salts)

1

3 Answers 3

3

You should use bcrypt.

Sign up to request clarification or add additional context in comments.

3 Comments

My question then is why? How much faster can you crack SHA256 than bcrypt? Especially if I do multiple iterations of SHA256?
@Earlz bcrypt lets you use a work factor. If it (argument's sake) SHA256 runs 30 times a second, and bcrypt runs once, then SHA256 will be 30 times quicker to crack (in theory, at least :D )
The link provided explains why: you define a "work factor", which will determine how fast/slow it is, and how much work a brute force attacker would have to do.
1

At the time of writing SHA256 is adequate for password protection, though it may not be in a year or so.

I'd maybe use SHA512 as I'm not too well traversed in what is really secure at the moment, and I'm not sure if anything can be really secure, with the huge increases of computing power in CPU's and GPU's.

Comments

1

Mike Howard's answer on the question Mark linked to is the correct best practice.
Simply using a good hash is insufficient because:

  • it does not protect you from rainbow table attacks. The same password will hash to the same result, every time. An attacker can compromise on the time vs. space tradeoff, pre-compute the most popular passwords and simply look up the answer. To defeat, you need to add a salt. (Mike suggests user id)

  • as you suggest, hashing algorithms are designed to be fast. This is sometimes desired, (such as getting the hash of a 50MB file) but in the case of passwords it not. Use a password-based key derivation function instead. It will significantly slow down an attacker, but not impact your own speed.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.