mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
eslint autofix
This commit is contained in:
parent
0d42541860
commit
ad730d806b
60 changed files with 13067 additions and 13014 deletions
|
@ -7,24 +7,24 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Endian = {
|
||||
|
||||
const Endian = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
DATA_FORMAT: ["Hex", "Raw"],
|
||||
DATA_FORMAT: ['Hex', 'Raw'],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
WORD_LENGTH: 4,
|
||||
WORD_LENGTH: 4,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PAD_INCOMPLETE_WORDS: true,
|
||||
|
||||
PAD_INCOMPLETE_WORDS: true,
|
||||
|
||||
/**
|
||||
* Swap endianness operation.
|
||||
*
|
||||
|
@ -32,63 +32,63 @@ var Endian = {
|
|||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run_swap_endianness: function(input, args) {
|
||||
var data_format = args[0],
|
||||
word_length = args[1],
|
||||
pad_incomplete_words = args[2],
|
||||
data = [],
|
||||
result = [],
|
||||
words = [],
|
||||
i = 0,
|
||||
j = 0;
|
||||
|
||||
if (word_length <= 0) {
|
||||
return "Word length must be greater than 0";
|
||||
}
|
||||
|
||||
run_swap_endianness(input, args) {
|
||||
let data_format = args[0],
|
||||
word_length = args[1],
|
||||
pad_incomplete_words = args[2],
|
||||
data = [],
|
||||
result = [],
|
||||
words = [],
|
||||
i = 0,
|
||||
j = 0;
|
||||
|
||||
if (word_length <= 0) {
|
||||
return 'Word length must be greater than 0';
|
||||
}
|
||||
|
||||
// Convert input to raw data based on specified data format
|
||||
switch (data_format) {
|
||||
case "Hex":
|
||||
data = Utils.from_hex(input);
|
||||
break;
|
||||
case "Raw":
|
||||
data = Utils.str_to_byte_array(input);
|
||||
break;
|
||||
default:
|
||||
data = input;
|
||||
}
|
||||
|
||||
switch (data_format) {
|
||||
case 'Hex':
|
||||
data = Utils.from_hex(input);
|
||||
break;
|
||||
case 'Raw':
|
||||
data = Utils.str_to_byte_array(input);
|
||||
break;
|
||||
default:
|
||||
data = input;
|
||||
}
|
||||
|
||||
// Split up into words
|
||||
for (i = 0; i < data.length; i += word_length) {
|
||||
var word = data.slice(i, i + word_length);
|
||||
|
||||
for (i = 0; i < data.length; i += word_length) {
|
||||
const word = data.slice(i, i + word_length);
|
||||
|
||||
// Pad word if too short
|
||||
if (pad_incomplete_words && word.length < word_length){
|
||||
for (j = word.length; j < word_length; j++) {
|
||||
word.push(0);
|
||||
}
|
||||
}
|
||||
|
||||
words.push(word);
|
||||
if (pad_incomplete_words && word.length < word_length) {
|
||||
for (j = word.length; j < word_length; j++) {
|
||||
word.push(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
words.push(word);
|
||||
}
|
||||
|
||||
// Swap endianness and flatten
|
||||
for (i = 0; i < words.length; i++) {
|
||||
j = words[i].length;
|
||||
while (j--) {
|
||||
result.push(words[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < words.length; i++) {
|
||||
j = words[i].length;
|
||||
while (j--) {
|
||||
result.push(words[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert data back to specified data format
|
||||
switch (data_format) {
|
||||
case "Hex":
|
||||
return Utils.to_hex(result);
|
||||
case "Raw":
|
||||
return Utils.byte_array_to_utf8(result);
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
switch (data_format) {
|
||||
case 'Hex':
|
||||
return Utils.to_hex(result);
|
||||
case 'Raw':
|
||||
return Utils.byte_array_to_utf8(result);
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue