World's most popular travel blog for travel bloggers.

Generate collision resistant identifiers with two-way hashing

, , No Comments
Problem Detail: 

Objective: We want to generate a unique and reproducible identifier for a given slice of bytes and avoid collisions.

High-level idea: Compute $$fK := hash(k_1)\; and\; sK := hash(k_1^{-1})\; where\; k_i^{-1}\; is\; the\; reversed\; bitstring\; k_i$$

We then proceed to set, our identifier to be: $$<value\_of\_fK>\_<value\_of\_sK>$$


For two keys $$k_1\; and\; k_2,\; if\; hash(k_1) = hash(k_2)\; and\; hash(k_1^{-1}) = hashs(k_2^{-1})\; then\; k_1 = k_2$$

where our hash function is FNV1a.

Hypothesis: For any given input bitstring, we will have a unique identifier and no collisions.

I would like to have your input on this

Asked By : Erwan Aaron
Answered By : Yuval Filmus

Your assumption is probably false. It can only be true if the size of the hash is at least half the size of the key.

If you want to generate an absolutely unique identifier, why not use the key itself? Another option, if you want an alphanumeric identifier, is to use Base64 (which also uses a few punctuation marks).

If you just want a practically unique identifier, you can just use a hash function – any industry-standard one would do. That's exactly their goal. Since it doesn't seem you care about cryptographic security, you can just use MD5 or SHA1.

Best Answer from StackOverflow

Question Source :

3200 people like this

 Download Related Notes/Documents


Post a Comment

Let us know your responses and feedback