import math


def compute_shannon(data):
    """
    Calculate Shannon entropy value for a given byte array.

    Keyword arguments:
    data -- data bytes
    """
    entropy = 0
    for x in range(256):
        it = float(data.count(x))/len(data)
        if it > 0:
            entropy += - it * math.log(it, 2)

    return entropy