Compare Hash Values
807601Mar 8 2008 — edited Mar 9 2008Not for an assignment or anything - I'm just interested!
I'm writing a simple backup program which will (hopefully) backup files automatically to external storage (just straight file copying - no gnarly encryption or anything).
Obviously I'm going to need to compare each file ("file") with it's backup version ("fileBKUP"). Rather than drag each fileBKUP from external storage and compare it with each file verbatim, I was thinking of:
1) creating a hash value for each fileBKUP as it's created and storing them in a file
2) at backup time copy these hash values into an array
3) cycle through files, creating hash value for each file and see if it's in the array of hashes
4) if it is, skip the file, if not back up the file and add the new hash value to the hash array and delete the old hash value (if the fileBKUP was indeed there at all)
5) after the last file, write the new hash values to the hash values file
Does this make any sense? Can hashes be used for this? Have I got this totally wrong? If this is going to fall flat on its face, what would you do to avoid dragging every file from the ext filestore?
Many thanks,
Anthony