'Check the security hash.'

def clean_security_hash(self):

    security_hash_dict = {'content_type': self.data.get('content_type', ''), 'object_pk': self.data.get('object_pk', ''), 'timestamp': self.data.get('timestamp', '')}
    expected_hash = self.generate_security_hash(**security_hash_dict)
    actual_hash = self.cleaned_data['security_hash']
    if (not constant_time_compare(expected_hash, actual_hash)):
        expected_hash_old = self._generate_security_hash_old(**security_hash_dict)
        if (not constant_time_compare(expected_hash_old, actual_hash)):
            raise forms.ValidationError('Security    hash    check    failed.')
    return actual_hash
