开发者

Length of SHA1 hash to identify an object?

开发者 https://www.devze.com 2023-02-19 07:42 出处:网络
Can I create a really short SHA1 hash to uniquely identify an object开发者_运维百科 that would typically have an id like 1300992607?

Can I create a really short SHA1 hash to uniquely identify an object开发者_运维百科 that would typically have an id like 1300992607?

This is relatively a theoretical question but how short can a SHA1 hash be and still be unique for an objects id? Please help me if not asking the right question here.


No, you can't, a hash doesn't work that way.

You can create a hash for the id, and just take as many bits you like from it. The more bits you use, the less likely it is that you get a hash that is the same for two different id, but no matter how many bits you use from the hash there is still no guarantee that there will never be a collision.

0

精彩评论

暂无评论...
验证码 换一张
取 消