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