import hashlib
import zipfile
import six


def get_zip_hash(obj):
    """Return a consistent hash of the content of a zip file ``obj``."""
    digest = hashlib.sha1()
    zfile = zipfile.ZipFile(obj, 'r')
    for path in sorted(zfile.namelist()):
        digest.update(six.text_type(path).encode('utf-8'))
        digest.update(zfile.read(path))
    return digest.hexdigest()