code: def calculate_shannon_entropy(self, data):
          
          if not data:  # pragma: no cover
              return 0
  
          entropy = 0
          for x in self.charset:
              p_x = float(data.count(x)) / len(data)
              if p_x > 0:
                  entropy += - p_x * math.log(p_x, 2)
  
          return entropy
docs: Returns the entropy of a given string.
  
          Borrowed from: http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html.
  
          :param data:  string. The word to analyze.
          :returns:       float, between 0.0 and 8.0