How to calculate the entropy of a file?
问题 How to calculate the entropy of a file? (Or let\'s just say a bunch of bytes) I have an idea, but I\'m not sure that it\'s mathematically correct. My idea is the following: Create an array of 256 integers (all zeros). Traverse through the file and for each of its bytes, increment the corresponding position in the array. At the end: Calculate the \"average\" value for the array. Initialize a counter with zero, and for each of the array\'s entries: add the entry\'s difference to \"average\" to