I want to guarantee the integrity of a message $m$. My first thought is to append the message to an integrity key $k$ and hash it as $H(k\,||\,m)$. However, I have been told that this is not totally secure, because an attacker can add more data to the end of $m$ while still generating the correct MAC.
How is it possible for an attacker to modify $H(k\,||\,m)$ such that the message is changed but the MAC is the same?
I was advised to use HMAC instead. Why does HMAC solve this problem?