Search code examples
algorithmcakephpcakephp-2.0checksum

Checksum on slides content


I have trainings which contain slides. When user request to load the training, all its slides are copy to view_slides table. But I don't want to copy those slides on each training load, so I want to check if training owner changed something on his slides. If he was, I will replace copy of slides by new ones.

The question is - how to check if something changed? I think, that I should load all slides content and check if there were changes, but how can I do it efficiently? Can I use checksum like for example MD5?


Solution

  • For non-security purposes, all the usual hash functions, such as MD5 or SHA, are fine. The problem with collisions for MD5, say, is related to attacks where such collisions are carefully crafted, not to a situation where you use a hash function to detect changed content.

    Also, you can hash any content, not only text. If the slides are PPTs you can hash the PPT files themselves, i.e. read the binary content of a file, run it through a hash function, and save the hash value, or some part of it.