mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Variable names changed from underscore to CamelCase. Eslint rules updated. #64
This commit is contained in:
parent
f8193797fa
commit
e3c977934b
66 changed files with 3176 additions and 3172 deletions
|
@ -30,14 +30,14 @@ var Hexdump = {
|
|||
/**
|
||||
* To Hexdump operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run_to: function(input, args) {
|
||||
runTo: function(input, args) {
|
||||
var length = args[0] || Hexdump.WIDTH;
|
||||
var upper_case = args[1];
|
||||
var include_final_length = args[2];
|
||||
var upperCase = args[1];
|
||||
var includeFinalLength = args[2];
|
||||
|
||||
var output = "", padding = 2;
|
||||
for (var i = 0; i < input.length; i += length) {
|
||||
|
@ -47,18 +47,18 @@ var Hexdump = {
|
|||
hexa += Utils.hex(buff[j], padding) + " ";
|
||||
}
|
||||
|
||||
var line_no = Utils.hex(i, 8);
|
||||
var lineNo = Utils.hex(i, 8);
|
||||
|
||||
if (upper_case) {
|
||||
if (upperCase) {
|
||||
hexa = hexa.toUpperCase();
|
||||
line_no = line_no.toUpperCase();
|
||||
lineNo = lineNo.toUpperCase();
|
||||
}
|
||||
|
||||
output += line_no + " " +
|
||||
Utils.pad_right(hexa, (length*(padding+1))) +
|
||||
" |" + Utils.pad_right(Utils.printable(Utils.byte_array_to_chars(buff)), buff.length) + "|\n";
|
||||
output += lineNo + " " +
|
||||
Utils.padRight(hexa, (length*(padding+1))) +
|
||||
" |" + Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length) + "|\n";
|
||||
|
||||
if (include_final_length && i+buff.length === input.length) {
|
||||
if (includeFinalLength && i+buff.length === input.length) {
|
||||
output += Utils.hex(i+buff.length, 8) + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -72,15 +72,15 @@ var Hexdump = {
|
|||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
run_from: function(input, args) {
|
||||
runFrom: function(input, args) {
|
||||
var output = [],
|
||||
regex = /^\s*(?:[\dA-F]{4,16}:?)?\s*((?:[\dA-F]{2}\s){1,8}(?:\s|[\dA-F]{2}-)(?:[\dA-F]{2}\s){1,8}|(?:[\dA-F]{2}\s|[\dA-F]{4}\s)+)/igm,
|
||||
block, line;
|
||||
|
||||
while ((block = regex.exec(input))) {
|
||||
line = Utils.from_hex(block[1].replace(/-/g, " "));
|
||||
line = Utils.fromHex(block[1].replace(/-/g, " "));
|
||||
for (var i = 0; i < line.length; i++) {
|
||||
output.push(line[i]);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ var Hexdump = {
|
|||
var w = (width - 13) / 4;
|
||||
// w should be the specified width of the hexdump and therefore a round number
|
||||
if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) {
|
||||
app.options.attempt_highlight = false;
|
||||
app.options.attemptHighlight = false;
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
@ -105,7 +105,7 @@ var Hexdump = {
|
|||
* @param {Object[]} args
|
||||
* @returns {Object[]} pos
|
||||
*/
|
||||
highlight_to: function(pos, args) {
|
||||
highlightTo: function(pos, args) {
|
||||
// Calculate overall selection
|
||||
var w = args[0] || 16,
|
||||
width = 14 + (w*4),
|
||||
|
@ -125,32 +125,32 @@ var Hexdump = {
|
|||
pos[0].end = line*width + 10 + offset*3 - 1;
|
||||
|
||||
// Set up multiple selections for bytes
|
||||
var start_line_num = Math.floor(pos[0].start / width);
|
||||
var end_line_num = Math.floor(pos[0].end / width);
|
||||
var startLineNum = Math.floor(pos[0].start / width);
|
||||
var endLineNum = Math.floor(pos[0].end / width);
|
||||
|
||||
if (start_line_num === end_line_num) {
|
||||
if (startLineNum === endLineNum) {
|
||||
pos.push(pos[0]);
|
||||
} else {
|
||||
start = pos[0].start;
|
||||
end = (start_line_num+1) * width - w - 5;
|
||||
end = (startLineNum+1) * width - w - 5;
|
||||
pos.push({ start: start, end: end });
|
||||
while (end < pos[0].end) {
|
||||
start_line_num++;
|
||||
start = start_line_num * width + 10;
|
||||
end = (start_line_num+1) * width - w - 5;
|
||||
startLineNum++;
|
||||
start = startLineNum * width + 10;
|
||||
end = (startLineNum+1) * width - w - 5;
|
||||
if (end > pos[0].end) end = pos[0].end;
|
||||
pos.push({ start: start, end: end });
|
||||
}
|
||||
}
|
||||
|
||||
// Set up multiple selections for ASCII
|
||||
var len = pos.length, line_num = 0;
|
||||
var len = pos.length, lineNum = 0;
|
||||
start = 0;
|
||||
end = 0;
|
||||
for (var i = 1; i < len; i++) {
|
||||
line_num = Math.floor(pos[i].start / width);
|
||||
start = (((pos[i].start - (line_num * width)) - 10) / 3) + (width - w -2) + (line_num * width);
|
||||
end = (((pos[i].end + 1 - (line_num * width)) - 10) / 3) + (width - w -2) + (line_num * width);
|
||||
lineNum = Math.floor(pos[i].start / width);
|
||||
start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
|
||||
end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width);
|
||||
pos.push({ start: start, end: end });
|
||||
}
|
||||
return pos;
|
||||
|
@ -166,7 +166,7 @@ var Hexdump = {
|
|||
* @param {Object[]} args
|
||||
* @returns {Object[]} pos
|
||||
*/
|
||||
highlight_from: function(pos, args) {
|
||||
highlightFrom: function(pos, args) {
|
||||
var w = args[0] || 16;
|
||||
var width = 14 + (w*4);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue