mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 08:41:32 -04:00
Adding the extract entropies operation
This commit is contained in:
parent
928178716a
commit
4762cc5442
1 changed files with 67 additions and 0 deletions
67
src/core/operations/ExtractEntropies.mjs
Normal file
67
src/core/operations/ExtractEntropies.mjs
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import Entropy from "./Entropy.mjs";
|
||||
|
||||
/**
|
||||
* Extract Entropies operation
|
||||
*/
|
||||
class ExtractEntropies extends Operation {
|
||||
|
||||
/**
|
||||
* ExtractEntropies constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Extract Entropies";
|
||||
this.module = "Default";
|
||||
this.description = "";
|
||||
this.infoURL = "";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "List<File>";
|
||||
this.args = [
|
||||
{
|
||||
name: "Entropies",
|
||||
type: "option",
|
||||
value: ["High", "Low", "High and Low", "Value Range"]
|
||||
},
|
||||
{
|
||||
name: "Upper bound Entropy",
|
||||
type: "number",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Lower bound Entropy",
|
||||
type: "number",
|
||||
value: ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {List<File>}
|
||||
*/
|
||||
run(input, args) {
|
||||
let entropies = new Entropy().calculateScanningEntropy(new Uint8Array(input));
|
||||
let currentMin = [8, -1];
|
||||
entropies.entropyData.forEach((element, index) => {
|
||||
if (element < currentMin[0]) {
|
||||
currentMin = [element, index]
|
||||
}
|
||||
});
|
||||
console.log(currentMin);
|
||||
|
||||
return " ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ExtractEntropies;
|
Loading…
Add table
Add a link
Reference in a new issue