# Whether hash function of two values $h(a,b)=h(b,a)$ are same?

If two messages $M_1$ and $M_2$ are given as input to a hash function $h$ is it then true that $h(M_1,M_2) = h(M_2,M_1)$?

I have two messages. I want to know,

1. Is it possible to apply a hash function to two messages?
2. If it so is $h(M_1,M_2)=h(M_2,M_1)$ ?
• I edited your question to make it a little more clear. I hope you find that it is still asking the same question. – Guut Boy Oct 6 '16 at 13:16

Starting from a normal hash function of $n$ bits $h:\{0,1\}^*\to\{0,1\}^n$, define $$h(a,b)=h(\;\min(h(a),h(b))\;\|\;\max(h(a),h(b))\;)$$ where $\|$ denotes concatenation of bitstrings, and order of bitstrings for $\min$ and $\max$ is lexicographic.
Trivially, $h(a,b)=h(b,a)$. First premimage resistance is kept. Other security properties (collision resistance, second preimage resistance, security in the Random Oracle Model) need adaptations, but follow from that of the one-argument $h$.
For some uses (including some Proof of Work protocols; see this for more), as well as making proofs stronger/easier, we might need a different inner and outer hash; like $$h(a,b)=h(\;\;\text{‘1’}\;\|\;\min(h(\text{‘0’}\|a),h(\text{‘0’}\|b))\;\|\;\max(h(\text{‘0’}\|a),h(\text{‘0’}\|b))\;)$$