mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
autofix no-var
This commit is contained in:
parent
31e5d785fe
commit
b33f73ac9a
61 changed files with 699 additions and 698 deletions
|
@ -26,7 +26,7 @@ const Entropy = {
|
|||
* @returns {html}
|
||||
*/
|
||||
runEntropy: function(input, args) {
|
||||
var chunkSize = args[0],
|
||||
let chunkSize = args[0],
|
||||
output = "",
|
||||
entropy = Entropy._calcEntropy(input);
|
||||
|
||||
|
@ -58,9 +58,9 @@ const Entropy = {
|
|||
]);\
|
||||
</script>";
|
||||
|
||||
var chunkEntropy = 0;
|
||||
let chunkEntropy = 0;
|
||||
if (chunkSize !== 0) {
|
||||
for (var i = 0; i < input.length; i += chunkSize) {
|
||||
for (let i = 0; i < input.length; i += chunkSize) {
|
||||
chunkEntropy = Entropy._calcEntropy(input.slice(i, i+chunkSize));
|
||||
output += "Bytes " + i + " to " + (i+chunkSize) + ": " + chunkEntropy + "\n";
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ const Entropy = {
|
|||
runFreqDistrib: function (input, args) {
|
||||
if (!input.length) return "No data";
|
||||
|
||||
var distrib = new Array(256),
|
||||
let distrib = new Array(256),
|
||||
percentages = new Array(256),
|
||||
len = input.length,
|
||||
showZeroes = args[0];
|
||||
|
@ -104,14 +104,14 @@ const Entropy = {
|
|||
}
|
||||
|
||||
// Calculate percentages
|
||||
var repr = 0;
|
||||
let repr = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (distrib[i] > 0) repr++;
|
||||
percentages[i] = distrib[i] / len * 100;
|
||||
}
|
||||
|
||||
// Print
|
||||
var output = "<canvas id='chart-area'></canvas><br>" +
|
||||
let output = "<canvas id='chart-area'></canvas><br>" +
|
||||
"Total data length: " + len +
|
||||
"\nNumber of bytes represented: " + repr +
|
||||
"\nNumber of bytes not represented: " + (256-repr) +
|
||||
|
@ -147,7 +147,7 @@ const Entropy = {
|
|||
* @returns {number}
|
||||
*/
|
||||
_calcEntropy: function(data) {
|
||||
var prob = [],
|
||||
let prob = [],
|
||||
uniques = data.unique(),
|
||||
str = Utils.byteArrayToChars(data);
|
||||
|
||||
|
@ -155,7 +155,7 @@ const Entropy = {
|
|||
prob.push(str.count(Utils.chr(uniques[i])) / data.length);
|
||||
}
|
||||
|
||||
var entropy = 0,
|
||||
let entropy = 0,
|
||||
p;
|
||||
|
||||
for (i = 0; i < prob.length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue