def hash_of_file(path):
 with open(path, 'rb') as archive:
  sha = sha256()
  while True:
   data = archive.read((2 ** 20))
   if (not data):
    break
   sha.update(data)
 return encoded_hash(sha)

def hash_of_file ( path ) : with open ( path , 'rb' ) as archive : sha = sha256 ( ) while True : data = archive . read ( ( 2 ** 20 ) ) if ( not data ) : break sha . update ( data ) return encoded_hash ( sha )
return the hash of a downloaded file .