2

Possible Duplicate:
Is SHA-1 secure for password storage?

I am new to encryption and I have a doubt. It may be a stupid question but I am going to ask. I know SHA1 is not decrypt-able. But a quick thought, if a hacker create a table containing two columns - non encrypted password and its SHA1 encrypted value. And the rows contains passwords of all combinations of characters which he generated using a program in 6 months (say 900 million records). Can't he easily get the non encrypted password if he got an SHA1 encrypted password?

If yes is there any solution to prevent this?

Thanks in advance.

3
  • Where did your value of 900 million records come from? As an example, passwords of 8 letters or digits give 2.18*10^14 possibilities.
    – Jon Skeet
    Jun 13, 2012 at 6:26
  • Don't take that count seriously:D I just used it to say that the hacker have all combinations of passwords in his db.
    – Matt
    Jun 13, 2012 at 6:28
  • 1
    What you are referring to is a rainbow table. Apart from that, this question is a duplicate. Jun 13, 2012 at 6:29

4 Answers 4

8

The attack you’re describing is called a rainbow table. Yes, it certainly is a valid concern for short passwords – thus the typical security requirements on the minimum length of passwords. However, the size of the table needs to grow exponentially with the length of the password; for example, an alphanumeric case-sensitive password would increase the table by a factor of 62 for each additional character. Thus, it becomes intractable to compute beyond a certain length. (Just 8 characters would give rise to around 218 trillion combinations.)

Another precaution you could take is to salt your passwords (which may simplistically involve appending a constant string to each password before computing its hash). This way, even if the attacker has access to a pre-computed rainbow table, it would be of no use against your hashes; a new rainbow table would have to be computed for each salt.

5

The common solution to prevent rainbow table attacks is using a Salt.

I would add though, that SHA1 is not considered very secure. Using brute force to find the unscrambled passwords is quite easy with a powerful computer. For storing passwords, it's recommended to use a slow hashing algorithm like bcrypt or PBKDF2.

1

Yes. That is why its important to salt your hash. As long as your has is properly salted the type of table you are talking about is only useful for a single password.

see http://msdn.microsoft.com/en-us/magazine/cc164107.aspx for example

1

A dictionary attack, such as the one you described, can be prevented by salting the hash. Essentially, you force the length and complexity of the plaintext beyond the scope of the dictionary being used.

It's simple to implement, too. One way is to maintain a password, such as "0shunF1ave" and attach it to your plaintext. So, instead of storing SHA1(password), you'd store SHA1("0shunF1ave"+password). When you verify the password, you perform the same hash against the candidate like SHA1("0shunF1av1"+candidate) to your originally stored hash and see if they match.

Not the answer you're looking for? Browse other questions tagged or ask your own question.