#NEWLINE# def _get_hash( obj ) : #NEWLINE# #INDENT# '\n    Returns a SHA512 object for the given object. Works in a similar fashion\n    to a Merkle tree (see https://en.wikipedia.org/wiki/Merkle_tree) should\n    the object be tree like in structure - but only returns the "root" hash.\n    ' #NEWLINE# obj_type = type ( obj ) #NEWLINE# if ( obj_type is dict ) : #NEWLINE# #INDENT# hash_list = [ ] #NEWLINE# for k in sorted ( obj ) : #NEWLINE# #INDENT# hash_list . append ( _get_hash ( k ) . hexdigest ( ) ) #NEWLINE# hash_list . append ( _get_hash ( obj [ k ] ) . hexdigest ( ) ) #NEWLINE# #UNINDENT# seed = '' . join ( hash_list ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( obj_type is list ) : #NEWLINE# #INDENT# hash_list = [ ] #NEWLINE# for item in obj : #NEWLINE# #INDENT# hash_list . append ( _get_hash ( item ) . hexdigest ( ) ) #NEWLINE# #UNINDENT# seed = '' . join ( hash_list ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( obj_type is bool ) : #NEWLINE# #INDENT# seed = str ( obj ) . lower ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( obj_type is float ) : #NEWLINE# #INDENT# seed = repr ( obj ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( obj is None ) : #NEWLINE# #INDENT# seed = 'null' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# seed = str ( obj ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return SHA512 . new ( seed . encode ( 'utf-8' ) )