MD5 前有多少随机元素产生碰撞? [英] How many random elements before MD5 produces collisions?

查看:23
本文介绍了MD5 前有多少随机元素产生碰撞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon S3 上有一个图像库.对于每个图像,我将服务器上的源 URL 加上时间戳以获取唯一的文件名.由于 S3 不能有子目录,我需要将所有这些图像存储在一个单一的文件夹中.

I've got an image library on Amazon S3. For each image, I md5 the source URL on my server plus a timestamp to get a unique filename. Since S3 can't have subdirectories, I need to store all of these images in a single flat folder.

我是否需要担心生成的 MD5 哈希值中的冲突?

Do I need to worry about collisions in the MD5 hash value that gets produced?

奖励:在我开始看到 MD5 生成的哈希值冲突之前,我可以拥有多少个文件?

Bonus: How many files could I have before I'd start seeing collisions in the hash value that MD5 produces?

推荐答案

两个 hash 意外碰撞的概率是 1/2128 这是 340 千分之一 282 十亿 366 非十亿 920 十亿 938 七百亿 463 六亿 463 千亿 437407 万亿 43740000000000000000000亿 7.68 亿 21.1 万 456.

Probability of just two hashes accidentally colliding is 1/2128 which is 1 in 340 undecillion 282 decillion 366 nonillion 920 octillion 938 septillion 463 sextillion 463 quintillion 374 quadrillion 607 trillion 431 billion 768 million 211 thousand 456.

但是,如果您保留所有哈希值,那么由于 生日悖论,概率会更高一些.要使任何散列有 50% 的机会与任何其他散列冲突,您需要 264 个散列.这意味着要发生碰撞,平均而言,您需要散列 6 十亿 个文件每秒 100 年.

However if you keep all the hashes then the probability is a bit higher thanks to birthday paradox. To have a 50% chance of any hash colliding with any other hash you need 264 hashes. This means that to get a collision, on average, you'll need to hash 6 billion files per second for 100 years.

这篇关于MD5 前有多少随机元素产生碰撞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆