JP Silvashy
JP Silvashy

Reputation: 48525

Length of SHA1 hash to identify an object?

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.

Upvotes: 0

Views: 859

Answers (1)

Guffa
Guffa

Reputation: 700432

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.

Upvotes: 1

Related Questions