Add support for multiple hash types with negotiation of common hash types for comparison. Manually rebased version of #277 (see discussion there)