I have a website where users can upload their files; they are stored on the server and their metadata recorded in the database. I perform some simple integrity checks, i.e. "Is the contents of this file byte by byte identical, as when downloading it?"
Example: for the content, the userfile.jpghash is MD5 39f9031a154dc7ba105eb4f76f1a0fd4, and SHA-1 hash 878d8d667721e356bf6646bd2ec21fff50cdd4a9. If the contents of this file change, but has the same MD5 hash before and after, is it possible that the SHA-1 hash will also remain the same? (With hashing, sometimes you can get a hash collision - can this happen with two different hashing algorithms at the same time?)
Or does it compute two different hashes for a file without meaning (and I should try a different integrity checker)?
Edit: I am not really worried about accidental damage, but I have to prevent users from quietly changing the file ( birthday attack and friends).
I'll probably go with one hash, SHA-512 - checks do not happen, which is often a performance bottleneck, and anyway, "As Bruce Schneier says, there are quite fast and insecure systems there. - @MichaelGG in the comments."
source
share