def _format_digest(digest, scheme, encoding):
    """Formats the arguments to a string: {scheme[.encoding]}digest."""
    if not encoding:
        return "{%s}%s" % (scheme, digest)
    return "{%s.%s}%s" % (scheme, encoding, digest)