import hashlib


def hash_file(filepath):
  """ Compute the md5 has for the specified file and return it as a hex string. """

  h = hashlib.md5()
  with open(filepath, 'rb') as f:
    for chunk in iter(lambda: f.read(8192), b''):
      h.update(chunk)

  return h.hexdigest()