def form_hmac(form):
 data = []
 for bf in form:
  if (form.empty_permitted and (not form.has_changed())):
   value = (bf.data or u'')
  else:
   value = (bf.field.clean(bf.data) or u'')
  if isinstance(value, six.string_types):
   value = value.strip()
  data.append((bf.name, value))
 pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
 key_salt = u'django.contrib.formtools'
 return salted_hmac(key_salt, pickled).hexdigest()

def form_hmac ( form ) : data = [ ] for bf in form : if ( form . empty_permitted and ( not form . has_changed ( ) ) ) : value = ( bf . data or u'' ) else : value = ( bf . field . clean ( bf . data ) or u'' ) if isinstance ( value , six . string_types ) : value = value . strip ( ) data . append ( ( bf . name , value ) ) pickled = pickle . dumps ( data , pickle . HIGHEST_PROTOCOL ) key_salt = u'django.contrib.formtools' return salted_hmac ( key_salt , pickled ) . hexdigest ( )
calculates a security hash for the given form instance .