# “Unique” number from several values

I'm trying to create a unique unsigned "long" number ($$64$$ bits) from a list of $$4$$ other numerical values. Some function $$f(n_1, n_2, n_3, n_4) = x$$. The order of the values is important so unfortunately I can't use this technique (calculating unique value from given numbers) which seems to give the same unique value from a set of numbers where order doesn't matter.

For example $$n_1 = 10, n_2 = 14, n_3 = 18, n_4 = 21$$ should be different than $$m_1 = 10, m_2 = 1, m_3 = 418, m_4 = 19$$. In addition, $$o_1 = 10, o_2 = 14, o_3 = 21, o_4 = 18$$ should also be different.

I realize it might not be possible to get a truly unique number due to the 64-bit limitation but if you can help me to find a number that's very unlikely to be unique, that would be very very nice:)

Other interesting suggestions that I've looked at:

Function for unique hash code

Deduce a unique number from number

Calculate unique Integer representing a pair of integers

Perhaps that last one could be applied three times? Since $$4$$ values are two pairs, each pair could generate a unique value and then the two unique values could be used in the function again?

• Thanks for your input and I realise designing hash functions for security reasons is a bad idea. I didn't realise Java's hashCode() actually returns an int. Thanks. hashCode() -> s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]. Since I'm in c++ I guess I'll build a string and use this: std::hash<std::string>()("foo");. Funny how googling can be this random after searching for 1 hour without results :P – span Feb 11 '14 at 15:49