'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'

@staticmethod
def _calc_entropy(data, size=None):

    if (not data):
        return 0
    entropy = 0
    if (size is None):
        size = len(data)
    data = str(pyvex.ffi.buffer(data, size))
    for x in xrange(0, 256):
        p_x = (float(data.count(chr(x))) / size)
        if (p_x > 0):
            entropy += ((- p_x) * math.log(p_x, 2))
    return entropy
