title: Why is XOR the default way to combine hashes?
body: <p>Say you have two hashes <code>H(A)</code> and <code>H(B)</code> and you want to combine them. I've read that a good way to combine two hashes is to <code>XOR</code> them, e.g. <code>XOR( H(A), H(B) )</code>.</p>
  
  <p>The best explanation I've found is touched briefly here on these <a href="http://www.javamex.com/tutorials/collections/hash_function_guidelines.shtml">hash function guidelines</a>:</p>
  
  <blockquote>
  XORing two numbers with roughly random distribution results in another number still with roughly random distribution*, but which now depends on the two values.
  <br/>
  ...
  <br/>
  * At each bit of the two numbers to combine, a 0 is output if the two bits are equal, else a 1. In other words, in 50% of the combinations, a 1 will be output. So if the two input bits each have a roughly 50-50 chance of being 0 or 1, then so too will the output bit.
  </blockquote>
  
  <p>Can you explain the intuition and/or mathematics behind why XOR should be the default operation for combining hash functions (rather than OR or AND etc.)?</p>