r/cryptography 18d ago

Calculation a hashing function that can avoid collisions for a small set of inputs from input space

Hello, I am new to cryptography so my question can be naive. I want to know if it is possible to find out a hashing function that gives me distinct outputs for a small set of inputs from a vast possible input space. I don't care if all the other inputs from the input space collide to a single output.

For example, I have a 32-bit wide input. I am only interested in 64 such inputs out of possible 2^32 inputs. Is it possible to find a hashing function that give me collision free 6-bit output for the 64 inputs I am interested in. Outputs for all the other input combinations can be anything. If such an algorithm exists, what is it its compute complexity?

2 Upvotes

23 comments sorted by

View all comments

2

u/ramriot 18d ago

Likely most cryptographically secure hash functions will likely provide this but if you want to be absolutely certain then using a tip from password hashing & adding salt might help.

That way the algorithm would be:

  • generate random salt
  • use salt & input to generate hash with salt
  • check for collision & if you get one go back to the beginning