code: def generate_hashes(filepath, blocksize=65536):
      '''Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blocksize can be any multiple of 128.'''
      # Init hashers
      hasher_md5 = hashlib.md5()
      hasher_sha1 = hashlib.sha1()
      # Read the file blocks by blocks
      with open(filepath, 'rb') as afile:
          buf = afile.read(blocksize)
          while len(buf) > 0:
              # Compute both hashes at the same time
              hasher_md5.update(buf)
              hasher_sha1.update(buf)
              # Load the next data block from file
              buf = afile.read(blocksize)
      return (hasher_md5.hexdigest(), hasher_sha1.hexdigest()f generate_hashes(filepath, blocksize=65536):
      '''Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blocksize can be any multiple of 128.'''
      # Init hashers
      hasher_md5 = hashlib.md5()
      hasher_sha1 = hashlib.sha1()
      # Read the file blocks by blocks
      with open(filepath, 'rb') as afile:
          buf = afile.read(blocksize)
          while len(buf) > 0:
              # Compute both hashes at the same time
              hasher_md5.update(buf)
              hasher_sha1.update(buf)
              # Load the next data block from file
              buf = afile.read(blocksize)
      return (hasher_md5.hexdigest(), hasher_sha1.hexdigest())
docs: Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blocksize can be any multiple of 128.