r/programminghelp • • Sep 06 '19

How does one go about creating a specialized non-cryptographic hash?

This question actually derives from a very specific problem I am currently tasked with solving. Essentially, I need to hash incoming values that are generated by a mathematical function into a hash table.

The function is g(x) = 4x + c, along the domain x ∈ [0, ~500], with the constant {c | 60000 ≤ c ≤ 4000000000, mod(c, 4) = 0}. I will not ever know the value of c.

How would one go about creating a uniformly distributed hash function for this input set?

3 Upvotes

1 comment sorted by

1

u/marko312 Sep 06 '19

I'm not sure what you want exactly - do you need a consistent mapping (hash function) lookup(x) -> g(x)? Or do you need a mapping from g(x) - lookup(g(x)) -> value?