def store_hash(filename):
    hash_string = myhash(filename)
with open(filename + ':hash') as fd:
    fd.write(hash_string)

def compare_hash(filename):
    hash_string = myhash(filename)
with open(filename + ':hash') as fd:
    orig = fd.read()
return hash_string == orig
Calculate and add hash to a file in python