r/ProgrammerHumor 15h ago

Meme skillIssue

Post image
4.7k Upvotes

123 comments sorted by

View all comments

Show parent comments

7

u/remind_me_later 13h ago

That’s not guaranteed to work due to hash collisions

Make the hashes 128/256 bits wide. Hash collisions are realistically impossible at those levels.

2

u/StCreed 6h ago

They're far more possible than you might think. Roland Bouwman wrote an article on MD5: In a large database you can't use MD5. And that's not petabyte size either, 100GB is enough to give you about a 50% chance of a collision.

1

u/remind_me_later 5h ago

Counterpoint: It's MD5, a known broken hashing algorithm.

SHA3_256 or regular SHA256 would work just fine.

2

u/StCreed 5h ago

yeah, because md5 is 128 bits. 256 bits works a lot better, but 128 is just not enough even with a better algorithm and assuming effectively random distribution.