From 4762cc5442ed01cb7bc846d758d828711f392ed8 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Tue, 17 Dec 2019 11:10:50 +0000 Subject: [PATCH] Adding the extract entropies operation --- src/core/operations/ExtractEntropies.mjs | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/core/operations/ExtractEntropies.mjs diff --git a/src/core/operations/ExtractEntropies.mjs b/src/core/operations/ExtractEntropies.mjs new file mode 100644 index 00000000..8ee1622f --- /dev/null +++ b/src/core/operations/ExtractEntropies.mjs @@ -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"; + 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} + */ + 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;