diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 354ec12e..0a4a6161 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -3287,7 +3287,7 @@ const OperationConfig = { "Frequency distribution": { module: "Default", description: "Displays the distribution of bytes in the data as a graph.", - inputType: "byteArray", + inputType: "ArrayBuffer", outputType: "html", args: [ { @@ -3300,7 +3300,7 @@ const OperationConfig = { "Chi Square": { module: "Default", description: "Calculates the Chi Square distribution of values.", - inputType: "byteArray", + inputType: "ArrayBuffer", outputType: "number", args: [] }, @@ -3740,7 +3740,7 @@ const OperationConfig = { "

", "EXIF data from photos usually contains information about the image file itself as well as the device used to create it.", ].join("\n"), - inputType: "byteArray", + inputType: "ArrayBuffer", outputType: "string", args: [], }, diff --git a/src/core/operations/Entropy.js b/src/core/operations/Entropy.js index aa9ed0bc..db860720 100755 --- a/src/core/operations/Entropy.js +++ b/src/core/operations/Entropy.js @@ -81,22 +81,23 @@ const Entropy = { /** * Frequency distribution operation. * - * @param {byteArray} input + * @param {ArrayBuffer} input * @param {Object[]} args * @returns {html} */ runFreqDistrib: function (input, args) { - if (!input.length) return "No data"; + const data = new Uint8Array(input); + if (!data.length) return "No data"; let distrib = new Array(256).fill(0), percentages = new Array(256), - len = input.length, + len = data.length, showZeroes = args[0], i; // Count bytes for (i = 0; i < len; i++) { - distrib[input[i]]++; + distrib[data[i]]++; } // Calculate percentages @@ -138,21 +139,22 @@ const Entropy = { /** * Chi Square operation. * - * @param {byteArray} data + * @param {ArrayBuffer} data * @param {Object[]} args * @returns {number} */ runChiSq: function(input, args) { + const data = new Uint8Array(input); let distArray = new Array(256).fill(0), total = 0; - for (let i = 0; i < input.length; i++) { - distArray[input[i]]++; + for (let i = 0; i < data.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); + total += Math.pow(distArray[i] - data.length / 256, 2) / (data.length / 256); } } diff --git a/src/core/operations/Image.js b/src/core/operations/Image.js index 2dd72df5..afab21c1 100644 --- a/src/core/operations/Image.js +++ b/src/core/operations/Image.js @@ -20,14 +20,13 @@ const Image = { * * Extracts EXIF data from a byteArray, representing a JPG or a TIFF image. * - * @param {byteArray} input + * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */ runExtractEXIF(input, args) { try { - const bytes = Uint8Array.from(input); - const parser = ExifParser.create(bytes.buffer); + const parser = ExifParser.create(input); const result = parser.parse(); let lines = []; @@ -53,7 +52,7 @@ const Image = { * @author David Moodie [davidmoodie12@gmail.com] * @param {byteArray} input * @param {Object[]} args - * @returns {string} + * @returns {byteArray} */ runRemoveEXIF(input, args) { // Do nothing if input is empty