import hmac
import hashlib


def hmac_generate(key, plaintext):
    """
    Generates an HMAC for the plaintext with the key.
    """
    h = hmac.new(key, msg=plaintext, digestmod=hashlib.sha256)
    h.update(plaintext)
    return h.digest()