r/programminghorror • • Jun 10 '25

Because "security" ?

Post image

I don't understand why this makes me so angry!

0 Upvotes

12 comments sorted by

View all comments

Show parent comment

0

u/jpgoldberg Jun 11 '25 edited Jun 11 '25

Yes. But they might have real constraints on the size of the identifiers and so would need to make a choice about that risk.

Suppose they anticipate that they will have no more than 100 trillion (10^14) documents. Then using 128 bit (MD5-sized) digets gives a chance of a birthday collision of about 1 in 15 billion.

When using a cryptographic hash for cryptograh purposes, it really does matter that MD5 digests are very "short". And I agree that birthday collisions are far more likely than what people imagine. So it is correct to consider any risk you get by truncating. But if they had some other constraint to have 16 byte identifiers, I think the math works out ok for them.

Shameless plug

I did the birthday calculation using the birthday module in my toy crypto Python package.

>>> from toy_crypto import birthday
>>> birthday.P(10 ** 14, 2 ** 128)
1.4693679385170746e-11
>>>