diff --git a/src/core/Utils.js b/src/core/Utils.js index a6ab48db..f9e5a3b8 100755 --- a/src/core/Utils.js +++ b/src/core/Utils.js @@ -438,7 +438,7 @@ const Utils = { /** * Converts a charcode array to a string. * - * @param {byteArray} byteArray + * @param {byteArray|Uint8Array} byteArray * @returns {string} * * @example @@ -477,7 +477,7 @@ const Utils = { /** * Base64's the input byte array using the given alphabet, returning a string. * - * @param {byteArray|string} data + * @param {byteArray|Uint8Array|string} data * @param {string} [alphabet] * @returns {string} * diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 15f00df8..dbac0bfe 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -245,7 +245,7 @@ const OperationConfig = { description: "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.

This operation encodes data in an ASCII Base64 string.

e.g. hello becomes aGVsbG8=", highlight: "func", highlightReverse: "func", - inputType: "byteArray", + inputType: "ArrayBuffer", outputType: "string", args: [ { @@ -782,7 +782,7 @@ const OperationConfig = { description: "Creates a hexdump of the input data, displaying both the hexadecimal values of each byte and an ASCII representation alongside.", highlight: "func", highlightReverse: "func", - inputType: "byteArray", + inputType: "ArrayBuffer", outputType: "string", args: [ { diff --git a/src/core/operations/Base64.js b/src/core/operations/Base64.js index c6d9ce6c..31c7e2a1 100755 --- a/src/core/operations/Base64.js +++ b/src/core/operations/Base64.js @@ -40,13 +40,13 @@ const Base64 = { /** * To Base64 operation. * - * @param {byteArray} input + * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */ runTo: function(input, args) { const alphabet = args[0] || Base64.ALPHABET; - return Utils.toBase64(input, alphabet); + return Utils.toBase64(new Uint8Array(input), alphabet); }, diff --git a/src/core/operations/Hexdump.js b/src/core/operations/Hexdump.js index 6b322b1f..fc907d9e 100755 --- a/src/core/operations/Hexdump.js +++ b/src/core/operations/Hexdump.js @@ -31,18 +31,19 @@ const Hexdump = { /** * To Hexdump operation. * - * @param {byteArray} input + * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */ runTo: function(input, args) { + const data = new Uint8Array(input); const length = args[0] || Hexdump.WIDTH; const upperCase = args[1]; const includeFinalLength = args[2]; let output = "", padding = 2; - for (let i = 0; i < input.length; i += length) { - const buff = input.slice(i, i+length); + for (let i = 0; i < data.length; i += length) { + const buff = data.slice(i, i+length); let hexa = ""; for (let j = 0; j < buff.length; j++) { hexa += Utils.hex(buff[j], padding) + " "; @@ -59,7 +60,7 @@ const Hexdump = { hexa.padEnd(length*(padding+1), " ") + " |" + Utils.printable(Utils.byteArrayToChars(buff)).padEnd(buff.length, " ") + "|\n"; - if (includeFinalLength && i+buff.length === input.length) { + if (includeFinalLength && i+buff.length === data.length) { output += Utils.hex(i+buff.length, 8) + "\n"; } }