def make_etag(hasher):
    """Build etag function based on `hasher` algorithm."""

    def etag(buf):
        h = hasher()
        for chunk in buf:
            h.update(chunk)
        return '"' + h.hexdigest() + '"'

    return etag