make a unique hash out of two strings
algorithm, scala
Solution
Another way is to hash both strings and xor the results. Since xor is commutative, the order doesn't matter. If the hashes are equal, don't xor them to avoid collisions with other pairs of identical strings.
Problem
Can anyone think of a way to make a unique hash out of two strings? Something that ensures: `hash(string1,string2) = hash(string2,string1).` I can always store the same reference under two different values in my map, but I thought: There must be a better way...