posted 13 years ago
Hi Moha,
as you have noticed correctly it is indeed a security problem if an intruder is able to manipulate a message and generate his own hash for the message when using hash functions like MD5. You would verify the manipulated message against the digest which would be manipulated, too, and you wouldn't even notice that the message was tampered with.
The simple answer to solve this problem is, that you have to prevent that this can happen :-) How you can avoid it practically depends very much on what you're doing. Is a network involved? Who or what uses the digest to verify messages? How do the message and the digest get to the other communication partner/computer if there is one? Do you only want to protect local data? This a real complex and difficult topic and depending on your needs sometimes a "simple" hash function like MD5 just won't be enough to protect your data sufficiently. For this there's unfortunately no general answer how to make something more secure with digests.
Perhaps you may give some more information about what you're trying to do if this answer didn't satisfy you?!?
Marco