How safe is it to rely on hashes for file identification?

后端 未结 2 663
迷失自我
迷失自我 2021-02-09 17:18

I am designing a storage cloud software on top of a LAMP stack.

Files could have an internal ID, but it would have many advantages to store them not with an incrementing

2条回答
  •  情歌与酒
    2021-02-09 18:07

    Whilst the probability of a collision might be vanishingly small, imagine serving a highly confidential file from one customer to their competitor just because there happens to be a hash collision.

    = end of business

    I'd rather use hashing for things that were less critical when collisions DO occur ;-)

    If you have a database, store the files under GUIDs - so not an incrementing index, but a proper globally unique identifier. They work nicely when it comes to distributed shards / high availability etc.

    Imagine the worst case scenario and assume it will happen the week after you are featured in wired magazine as an amazing startup ... that's a good stress test for the algorithm.

提交回复
热议问题