import hmac
import hashlib


def calculate_answer(nonce, password_hash):
    """
    Calculate Answer on Server
    -> Answer = HMAC(nonce, password_hash, sha256)

    :param nonce:
    :param password:

    :return: answer
    """

    answer = hmac.new(key=password_hash.encode(), msg=nonce.encode(), digestmod=hashlib.sha256)
    return answer.hexdigest()