I am trying to write a hash function to map a 64-bit integer to another "random-looking" 64 bit integer.
Here are my requirements:
- I can only use
/,*,+,-, andmod. - I can choose arbitrary constants, but they are fixed (in order for this to be a true function).
e.g., h(x) = mod(mod(x, 2^32) * mod(x + 3, 2^32), randPrime(2^15, 2^16) is a valid expression (2^32 and randPrime(2^15, 2^16) are fixed constants). (I pre-mod by 2^32 to avoid 64-bit overflow.)
However, this particular expression is very bad because very small values of x map to deterministic values. What are some ways to mitigate this problem, and create a distribution that looks fairly random?