Is it possible to construct a hash function that accepts multiple keys and returns the same value if at least one key is the same?

113 Views Asked by At

How to construct a hash function that accepts multiple keys as input and returns the same value if at least one input key is the same, no matter which keys are identical?

For example, the desired hash function $h(\cdot, \cdot, \cdot, \cdot)$ which takes four keys as input should satisfy that:

  • $h(a_1, b_1, c_1, d_1) = h(a_1, b_1, c_1, d_1)$   // equal if all keys are identical
  • $h(a_1, b_1, c_1, d_1) = h(a_1, b_1, c_1, d_2)$   // equal if at least one key is identical
  • $h(a_1, b_1, c_1, d_1) = h(a_1, b_2, c_2, d_2)$   // equal if at least one key is identical
  • $h(a_1, b_1, c_1, d_1) = h(a_1, b_1, c_2, d_1)$   // equal if at least one key is identical
  • $h(a_1, b_1, c_1, d_1) \neq h(a_2, b_2, c_2, d_2)$   // not equal if all keys are different

Note: the keys of my hash function are all the string.

To be honest, I have no idea on this problem. Simply concatenation or linear combination apparently does not work.