You want to create a hash code that can’t be replaced by a malicious user.
Combine hashing with encryption, either by using a keyed hash code or a digital signature.
Hash codes have one obvious limitation: unless you store the hash code in a secure location, there is nothing to stop an attacker from tampering with your data and generating a new hash code that matches the altered data. In this scenario, it would be impossible to detect that any change has taken place. This is a common problem in distributed applications, which use hash codes to validate messages that are sent over a network.
The solution is to create a hash code that an attacker won’t be able to recreate. For example, you can ...