def _hash(message, method_name):
 if (method_name not in HASH_METHODS):
  raise ValueError(('Invalid hash method: %s' % method_name))
 method = HASH_METHODS[method_name]
 hasher = method()
 if (hasattr(message, 'read') and hasattr(message.read, '__call__')):
  for block in varblock.yield_fixedblocks(message, 1024):
   hasher.update(block)
 else:
  hasher.update(message)
 return hasher.digest()

def _hash ( message , method_name ) : if ( method_name not in HASH_METHODS ) : raise ValueError ( ( 'Invalid hash method: %s' % method_name ) ) method = HASH_METHODS [ method_name ] hasher = method ( ) if ( hasattr ( message , 'read' ) and hasattr ( message . read , '__call__' ) ) : for block in varblock . yield_fixedblocks ( message , 1024 ) : hasher . update ( block ) else : hasher . update ( message ) return hasher . digest ( )
encode binary data according to specified algorithm .