I'm coding an application, and I'm looking for an algorithm that can tell me if a file has changed, without only using the file's timestamp. I was thinking of using something like a checksum.
This would be used for files < 20 MB in size, and on these files, it should be able to operate in a few seconds, preferably under 1s for files under 1 MB.
My idea was to store the last modified date, the checksum, and the file length for each file as it was discovered, and later, to use these as a test to determine if the file was modified or replaced; if all 3 match, the file is considered unchanged; if not, the file has been altered.
I just need a fast algorithm to generate some kind of checksum. Any resources?