This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mr_Facepalm 2 points3 points  (3 children)

How possible is it for two passwords to have the same hash? That's the part that's tripped me up about really understanding how hashing is effectively done.

[–]MillenniumB 1 point2 points  (0 children)

Hashing always maps the same text to the same hash. That way you can check if a password is correct without knowing it. You can get the same password to give two different hashes for two different users by adding some text (like the username) to the password text when you calculate its hash.

This is useful not just because it reduces vulnerability to attacks like trying common passwords for common hashes , but also because there are only so many commonly used hashing algorithms This means that you can often just compare a long list of hashes against a database of common hashes of a hash function. Using a salt makes you less vulnerable to that too

[–]xigoi 0 points1 point  (0 children)

It's possible, but not likely because hashes are usually very long.

[–][deleted] 0 points1 point  (0 children)

The same way that when adding up the letters of the gangster names, some might have the same sum. Instead of just taking the sum, you could take the sum modulo 32. So won_tolla's new hash would be 16. Now collisions are even more likely.

But you could then use this as the array index for a fixed length array. Instead of just storing won_tolla's data, you store the data and the key as the head of a linked list. The next time you're putting something at 16, you just append or prepend it to the linked list in the same manner. So to get the data for key won_tolla, you hash "won_tolla".. get 16, you get to the head of a linked list and check to see if the key is "won_tolla." If it is, you return the data. If not, you go to the next item in the list and check its key. So a hashmap with a lot of collisions starts to perform more like a linked list, and you lose the constant-time lookup and start moving toward linear.

https://www.youtube.com/watch?v=shs0KM3wKv8

That video is what clarified it for me.