import hashlib


def HashFileContents(filename):
  """Return the hash (sha1) of tthe contents of a file.

  Args:
    filename: Filename to read.
  Returns:
    The sha1 of a file.
  """
  hasher = hashlib.sha1()
  fh = open(filename, 'rb')
  try:
    while True:
      data = fh.read(4096)
      if not data:
        break
      hasher.update(data)
  finally:
    fh.close()
  return hasher.hexdigest()