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.
精彩评论