import hmac
import hashlib


def keyed_hash(digest, passphrase):
    """Calculate a HMAC/keyed hash.

    :param digest: Digest used to create hash.
    :type digest: str
    :param passphrase: Passphrase used to generate the hash.
    :type passphrase: str
    :returns: HMAC/keyed hash.
    :rtype: str
    """
    encodedPassphrase = passphrase.encode()
    encodedDigest = digest.encode()

    return hmac.new(encodedPassphrase, encodedDigest, hashlib.sha256).digest()