mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
changed the function comment
This commit is contained in:
parent
caae0ec5ca
commit
08a31523b2
4 changed files with 31 additions and 0 deletions
|
@ -163,6 +163,28 @@ const Entropy = {
|
|||
return -entropy;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the Chi Square distribution of values.
|
||||
*
|
||||
* @private
|
||||
* @param {byteArray} data
|
||||
* @param {Object[]} args
|
||||
* @returns {number}
|
||||
*/
|
||||
calcChiSq: function(input, args) {
|
||||
let distArray = new Array(256).fill(0),
|
||||
total = 0;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
distArray[data[i]]++;
|
||||
}
|
||||
for (let i = 0; i < distArray.length; i++) {
|
||||
if (distArray[i] > 0) {
|
||||
total += Math.pow(distArray[i] - input.length / 256, 2) / (input.length / 256);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
};
|
||||
|
||||
export default Entropy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue