How many random elements before MD5 produces collisions?

前端 未结 8 1937
执笔经年
执笔经年 2020-11-22 12:25

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

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 12:33

    Although random MD5 collisions are exceedingly rare, if your users can provide files (that will be stored verbatim) then they can engineer collisions to occur. That is, they can deliberately create two files with the same MD5sum but different data. Make sure your application can handle this case in a sensible way, or perhaps use a stronger hash like SHA-256.

提交回复
热议问题