Calculate and add hash to a file in python

Viewed 2170

a way of checking if a file has been modified, is calculating and storing a hash (or checksum) for the file. Then at any point the hash can be re-calculated and compared against the stored value.

I'm wondering if there is a way to store the hash of a file in the file itself? I'm thinking text files.

The algorithm to calculate the hash should be iterative and consider that the hash will be added to the file the hash is being calculated for... makes sense? Anything available?

Thanks!

edit: https://security.stackexchange.com/questions/3851/can-a-file-contain-its-md5sum-inside-it

3 Answers
Related