mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 16:51:31 -04:00
Revert "[#913] added groupings to hex dump" and move changes to a new PR
This reverts commit 150e66fc99
.
This commit is contained in:
parent
150e66fc99
commit
44cf916f43
1 changed files with 2 additions and 15 deletions
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
|
||||||
import Utils from "../Utils.mjs";
|
import Utils from "../Utils.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,11 +39,6 @@ class ToHexdump extends Operation {
|
||||||
"name": "Include final length",
|
"name": "Include final length",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": false
|
"value": false
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Output grouping",
|
|
||||||
"type": "number",
|
|
||||||
"value": 1
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -58,20 +52,13 @@ class ToHexdump extends Operation {
|
||||||
const data = new Uint8Array(input);
|
const data = new Uint8Array(input);
|
||||||
const [length, upperCase, includeFinalLength] = args;
|
const [length, upperCase, includeFinalLength] = args;
|
||||||
const padding = 2;
|
const padding = 2;
|
||||||
const groupSize = args[3] || 1;
|
|
||||||
if (length%groupSize !== 0){
|
|
||||||
throw new OperationError("The value of the width parameter must be divisible by the value of the output grouping parameter");
|
|
||||||
}
|
|
||||||
|
|
||||||
let output = "";
|
let output = "";
|
||||||
for (let i = 0; i < data.length; i += length) {
|
for (let i = 0; i < data.length; i += length) {
|
||||||
const buff = data.slice(i, i+length);
|
const buff = data.slice(i, i+length);
|
||||||
let hexa = "";
|
let hexa = "";
|
||||||
for (let j = 0; j < buff.length; j++) {
|
for (let j = 0; j < buff.length; j++) {
|
||||||
hexa += Utils.hex(buff[j], padding);
|
hexa += Utils.hex(buff[j], padding) + " ";
|
||||||
if (groupSize === 1 || (j > 0 && (j+1)%groupSize === 0)){
|
|
||||||
hexa += " ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let lineNo = Utils.hex(i, 8);
|
let lineNo = Utils.hex(i, 8);
|
||||||
|
@ -82,7 +69,7 @@ class ToHexdump extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
output += lineNo + " " +
|
output += lineNo + " " +
|
||||||
hexa.padEnd(length*padding+(length/groupSize), " ") +
|
hexa.padEnd(length*(padding+1), " ") +
|
||||||
" |" + Utils.printable(Utils.byteArrayToChars(buff)).padEnd(buff.length, " ") + "|\n";
|
" |" + Utils.printable(Utils.byteArrayToChars(buff)).padEnd(buff.length, " ") + "|\n";
|
||||||
|
|
||||||
if (includeFinalLength && i+buff.length === data.length) {
|
if (includeFinalLength && i+buff.length === data.length) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue