Cryptographically hash the answer with the provided timestamp

        This method allows the widget to securely generate time-sensitive
        signatures that will both prevent tampering with the answer as well as
        provide some protection against replay attacks by limiting how long a
        given signature is valid for. Using this same method, the field can
        validate the submitted answer against the signature also provided in
        the form.

def hash_answer(self, answer, timestamp):
        """Cryptographically hash the answer with the provided timestamp

        This method allows the widget to securely generate time-sensitive
        signatures that will both prevent tampering with the answer as well as
        provide some protection against replay attacks by limiting how long a
        given signature is valid for. Using this same method, the field can
        validate the submitted answer against the signature also provided in
        the form.
        """
        # Ensure our values are string before we start hashing
        timestamp = str(timestamp)
        answer = str(answer)
        hashed = ''

        # Hashing multiple times increases the security of the signature
        for _ in range(ITERATIONS):
            # We use Django's own "salted HMAC" for cryptographic signatures
            hashed = salted_hmac(timestamp, answer).hexdigest()

        return hashed