code: def _calc_entropy(data, size=None):
          
  
          if not data:
              return 0
          entropy = 0
          if size is None:
              size = len(data)
  
          data = bytes(pyvex.ffi.buffer(data, size))
          for x in range(0, 256):
              p_x = float(data.count(x)) / size
              if p_x > 0:
                  entropy += - p_x * math.log(p_x, 2)
          return entropy
docs: Calculate the entropy of a piece of data
  
          :param data: The target data to calculate entropy on
          :param size: Size of the data, Optional.
          :return: A float