# Hashing a tuple of maximum-valued integers

I'm considering a hash function for a tuple of and maximum-valued integers for example `(3 ,2, 5 )` -- where each element of the tuple has some maximum value `N`.

My plan is to treat the elements of the tuple as the digits of a number in base `N`, so that in the trivial case of `N = 10` the tuple`(3 ,2, 5 )` hashes to 325, or 213 if `N = 8`.

(1) Is this hashing technique flawed and (2) If not, does it have a name, and (3) Are there better ways to hash a tuple of integers.

• Are your Tuples uniformly distributed across [0:N]^3? Commented Jun 7, 2016 at 23:51
• It will work fine, if the maximum value of each number does not exceed `N-1`. In fact, it will work more than fine; there will be zero collisions. Commented Jun 8, 2016 at 0:00
• @Oxinabox I'm not sure. The tuples are intersection points from geometry. I'm hashing to assign ids to these points. Commented Jun 8, 2016 at 0:20
• What you're doing is encoding, not hashing since it's possible to decode the result into the original form. (assuming the absence of integer overflow) Commented Jun 8, 2016 at 10:18