mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Replaced jsHint with eslint. Fixes #4.
This commit is contained in:
parent
e2e68dd876
commit
af4644c9eb
48 changed files with 1741 additions and 1685 deletions
|
@ -44,14 +44,14 @@ var Base64 = {
|
|||
var alphabet = args[0] || Base64.ALPHABET;
|
||||
return Utils.to_base64(input, alphabet);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
REMOVE_NON_ALPH_CHARS: true,
|
||||
|
||||
|
||||
/**
|
||||
* From Base64 operation.
|
||||
*
|
||||
|
@ -62,17 +62,17 @@ var Base64 = {
|
|||
run_from: function(input, args) {
|
||||
var alphabet = args[0] || Base64.ALPHABET,
|
||||
remove_non_alph_chars = args[1];
|
||||
|
||||
|
||||
return Utils.from_base64(input, alphabet, "byte_array", remove_non_alph_chars);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
BASE32_ALPHABET: "A-Z2-7=",
|
||||
|
||||
|
||||
/**
|
||||
* To Base32 operation.
|
||||
*
|
||||
|
@ -82,7 +82,7 @@ var Base64 = {
|
|||
*/
|
||||
run_to_32: function(input, args) {
|
||||
if (!input) return "";
|
||||
|
||||
|
||||
var alphabet = args[0] ?
|
||||
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
||||
output = "",
|
||||
|
@ -115,16 +115,16 @@ var Base64 = {
|
|||
} else if (isNaN(chr5)) {
|
||||
enc8 = 32;
|
||||
}
|
||||
|
||||
|
||||
output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) +
|
||||
alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) +
|
||||
alphabet.charAt(enc7) + alphabet.charAt(enc8);
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* From Base32 operation.
|
||||
*
|
||||
|
@ -134,16 +134,16 @@ var Base64 = {
|
|||
*/
|
||||
run_from_32: function(input, args) {
|
||||
if (!input) return [];
|
||||
|
||||
|
||||
var alphabet = args[0] ?
|
||||
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
||||
remove_non_alph_chars = args[0];
|
||||
|
||||
|
||||
var output = [],
|
||||
chr1, chr2, chr3, chr4, chr5,
|
||||
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
|
||||
i = 0;
|
||||
|
||||
|
||||
if (remove_non_alph_chars) {
|
||||
var re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g");
|
||||
input = input.replace(re, "");
|
||||
|
@ -171,11 +171,11 @@ var Base64 = {
|
|||
if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4);
|
||||
if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5);
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -186,7 +186,7 @@ var Base64 = {
|
|||
* @default
|
||||
*/
|
||||
OFFSETS_SHOW_VARIABLE: true,
|
||||
|
||||
|
||||
/**
|
||||
* Show Base64 offsets operation.
|
||||
*
|
||||
|
@ -206,96 +206,96 @@ var Base64 = {
|
|||
script = "<script type='application/javascript'>$('[data-toggle=\"tooltip\"]').tooltip()</script>",
|
||||
static_section = "",
|
||||
padding = "";
|
||||
|
||||
|
||||
if (input.length < 1) {
|
||||
return "Please enter a string.";
|
||||
}
|
||||
|
||||
|
||||
// Highlight offset 0
|
||||
if (len0 % 4 == 2) {
|
||||
if (len0 % 4 === 2) {
|
||||
static_section = offset0.slice(0, -3);
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -2)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>";
|
||||
} else if (len0 % 4 == 3) {
|
||||
} else if (len0 % 4 === 3) {
|
||||
static_section = offset0.slice(0, -2);
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
|
||||
} else {
|
||||
static_section = offset0;
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64(static_section, alphabet)) + "'>" +
|
||||
static_section + "</span>";
|
||||
}
|
||||
|
||||
|
||||
if (!show_variable) {
|
||||
offset0 = static_section;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Highlight offset 1
|
||||
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" +
|
||||
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>";
|
||||
offset1 = offset1.substr(2);
|
||||
if (len1 % 4 == 2) {
|
||||
if (len1 % 4 === 2) {
|
||||
static_section = offset1.slice(0, -3);
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -2)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>";
|
||||
} else if (len1 % 4 == 3) {
|
||||
} else if (len1 % 4 === 3) {
|
||||
static_section = offset1.slice(0, -2);
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
|
||||
} else {
|
||||
static_section = offset1;
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1)) + "'>" +
|
||||
static_section + "</span>";
|
||||
}
|
||||
|
||||
|
||||
if (!show_variable) {
|
||||
offset1 = static_section;
|
||||
}
|
||||
|
||||
|
||||
// Highlight offset 2
|
||||
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" +
|
||||
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>";
|
||||
offset2 = offset2.substr(3);
|
||||
if (len2 % 4 == 2) {
|
||||
if (len2 % 4 === 2) {
|
||||
static_section = offset2.slice(0, -3);
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>";
|
||||
} else if (len2 % 4 == 3) {
|
||||
} else if (len2 % 4 === 3) {
|
||||
static_section = offset2.slice(0, -2);
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
|
||||
static_section + "</span>" +
|
||||
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
|
||||
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
|
||||
} else {
|
||||
static_section = offset2;
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
|
||||
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2)) + "'>" +
|
||||
static_section + "</span>";
|
||||
}
|
||||
|
||||
|
||||
if (!show_variable) {
|
||||
offset2 = static_section;
|
||||
}
|
||||
|
||||
|
||||
return (show_variable ? "Characters highlighted in <span class='hlgreen'>green</span> could change if the input is surrounded by more data." +
|
||||
"\nCharacters highlighted in <span class='hlred'>red</span> are for padding purposes only." +
|
||||
"\nUnhighlighted characters are <span data-toggle='tooltip' data-placement='top' title='Tooltip on left'>static</span>." +
|
||||
|
@ -306,8 +306,8 @@ var Base64 = {
|
|||
script :
|
||||
offset0 + "\n" + offset1 + "\n" + offset2);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Highlight to Base64
|
||||
*
|
||||
|
@ -322,7 +322,7 @@ var Base64 = {
|
|||
pos[0].end = Math.ceil(pos[0].end / 3 * 4);
|
||||
return pos;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Highlight from Base64
|
||||
*
|
||||
|
@ -337,5 +337,5 @@ var Base64 = {
|
|||
pos[0].end = Math.floor(pos[0].end / 4 * 3);
|
||||
return pos;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue