def gen_signature(hmac, data):
    """Creates a signature from the provided hmac and given data.

    :param hmac: The hmac instance to use to create a digest
    :param data: Collection of data to use when producing the signature;
                 each element should be a collection of bytes
    :returns: A digest in the form of a string representing the signature
    """
    h = hmac.copy()
    for d in data:
        h.update(d)
    return h.digest()